I constantly find myself passing config values to functions accessing them like this:
var arg1 = \'test1\';
if(isUndefined(config.args.arg1)){
arg1 = config.ar
With ES2018, you can now write options = { ...defaults, ...options }
:
Spread syntax - JavaScript | MDN
Shallow-cloning (excluding prototype) or merging of objects is now possible using a shorter syntax than Object.assign().
const obj1 = { foo: 'bar', x: 42 }; const obj2 = { foo: 'baz', y: 13 }; const clonedObj = { ...obj1 }; // Object { foo: "bar", x: 42 } const mergedObj = { ...obj1, ...obj2 }; // Object { foo: "baz", x: 42, y: 13 }