Skip to content

Instantly share code, notes, and snippets.

@odellt
Last active September 25, 2019 12:09
Show Gist options
  • Save odellt/18b1be6fcbf86afa072d7187fd3dea6a to your computer and use it in GitHub Desktop.
Save odellt/18b1be6fcbf86afa072d7187fd3dea6a to your computer and use it in GitHub Desktop.
Demonstration of default arguments in a function
function speak(phrase = 'Hello World!') {
console.log(phrase);
}
speak();
// Output: Hello World!
speak(undefined);
// Output: Hello World!
speak('Goodbye World!');
// Output: Goodbye World
speak(null);
// Output: null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment