Last active
March 2, 2018 15:28
-
-
Save marcelo-ribeiro/f7536e88d32dcb5e2ad4ee073e9a6377 to your computer and use it in GitHub Desktop.
ES6 defaults / overrides pattern
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
var defaults = { | |
bar: 'no', | |
baz: 'works!' | |
}; | |
function foo( options ) { | |
Object.assign( defaults, options ); | |
console.log( defaults ); | |
} | |
foo({ | |
bar: 'yay' | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment