Created
October 13, 2016 18:30
-
-
Save emilong/16cd6c379136dfb9baf0c1189495995c to your computer and use it in GitHub Desktop.
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 defaults({ 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 | |
// multiple params? no problem, just supply the ones you want | |
defaults({ a: 87 }); | |
// a 87 | |
// b 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment