Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.