Last active
July 25, 2016 12:15
-
-
Save davej/5d217e746484043dbee03753c11ec9f1 to your computer and use it in GitHub Desktop.
Options object merged with defaults in ES2015+
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 createSite(name, assignedOptions = {}) { | |
const defaultOptions = { | |
html: 'jade', | |
styles: 'scss', | |
scripts: 'babel', | |
whitespace: '2 spaces', | |
}; | |
const options = Object.assign({}, defaultOptions, assignedOptions); | |
/* | |
* In the future you will be able to use the spread operator instead of Object.assign(). | |
* It is currently at stage 2 of ECMAScript drafts. | |
* https://github.com/sebmarkbage/ecmascript-rest-spread | |
*/ | |
// const options = { | |
// ...defaultOptions, | |
// ...assignedOptions, | |
// }; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment