Skip to content

Instantly share code, notes, and snippets.

@davej
Last active July 25, 2016 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davej/5d217e746484043dbee03753c11ec9f1 to your computer and use it in GitHub Desktop.
Save davej/5d217e746484043dbee03753c11ec9f1 to your computer and use it in GitHub Desktop.
Options object merged with defaults in ES2015+
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