Suppose I have a function (possibly from a 3rd party library, assume I can't change its definition), and an object with properties that match or overlap the function's arguments:
function fn(foo, bar, baz) { /* do stuff */ }
var obj = { foo: "yes", bar: 7, baz: false }
Is there a way to apply the objects properties as the functions arguments using some kind of destructuring or spread assignment, or some other ES6 feature, or am I stuck with specifying each argument seperately?
fn(...obj); // Doesn't work
fn(obj.foo, obj.bar, obj.baz); // Convoluted but works
fn.apply(null, obj.values()); // Might work if you're lucky