Skip to content

Instantly share code, notes, and snippets.

@wrburgess
Created October 10, 2019 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wrburgess/68539ad61d232056c062ef1e2fa63040 to your computer and use it in GitHub Desktop.
Save wrburgess/68539ad61d232056c062ef1e2fa63040 to your computer and use it in GitHub Desktop.
javascript es6 default params
// 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