Yes, I'm very excited about the spread operator! I've been spoiled by Firefox.
function foo(a=1, b=2, c=3) { return a * b * c;}
dict = {'b': 4, 'c': 6};
foo(...dict);[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe... [2] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...
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 } const foo = ({ a = 2, b = 2, c = 3 } = {}) => a * b * c;
const dict = {b: 4, c: 6};
foo(); // 12
foo(dict); // 48