Created
October 13, 2016 18:28
-
-
Save emilong/3de06b9381dfe3a5a5700c4fe709cadc to your computer and use it in GitHub Desktop.
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
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