Last active
September 25, 2019 12:09
-
-
Save odellt/18b1be6fcbf86afa072d7187fd3dea6a to your computer and use it in GitHub Desktop.
Demonstration of default arguments in a function
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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