Created
October 10, 2019 15:58
-
-
Save wrburgess/68539ad61d232056c062ef1e2fa63040 to your computer and use it in GitHub Desktop.
javascript es6 default params
This file contains 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
// When you set a function parameter to `(arg = val)` that sets the default | |
// for the argument. It is not a forced assignment. | |
// | |
// Example: | |
function postSomething(name = 'Megan') { | |
console.log('name:', name); | |
} | |
postSomething(); // console logs 'name: Megan' | |
postSomething('Randy'); // console logs 'name: Randy' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment