Glad to see they've bumped up the V8 version so the spread operator can be used.
Things are really moving along at a good clip since the merge with io.js.
Things are really moving along at a good clip since the merge with io.js.
function foo(a=1, b=2, c=3) { return a * b * c;}
dict = {'b': 4, 'c': 6};
foo(...dict);You can still do something like:
foo(... Object.keys(dict).map(name => dict[name]))
(Maybe someday you might be able to use Object.values() to achieve the exact same thing without needing to use .map)However, the spread operator doesn't match the argument names to the object names. So the above call would mean the following:
foo(4, 6)
And not what you'd like: foo(undefined, 4, 6)
However, note that you can rest an object too: let x = { a : 1, b : 2, c : 3 };
let { a, ... rest } = x;
console.log( ... rest ); // { b : 2, c : 3 }[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... [2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
const foo = ({ a = 2, b = 2, c = 3 } = {}) => a * b * c;
const dict = {b: 4, c: 6};
foo(); // 12
foo(dict); // 48