Skip to content

Instantly share code, notes, and snippets.

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 webdesignberlin/0f9c416064194e2c80e39d34c9f1af4d to your computer and use it in GitHub Desktop.
Save webdesignberlin/0f9c416064194e2c80e39d34c9f1af4d to your computer and use it in GitHub Desktop.
function defaults({ a, b } = { a: 1, b: 2 }) {
console.log('a', a);
console.log('b', b);
}
defaults();
// a 1
// b 2
defaults({ a: 42, b: 32 });
// a 42
// b 32
// be careful with multiple params! The whole right-hand side
// is replaced with your argument!
defaults({ a: 87 });
// a 87
// b undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment