I have an object:
var obj = {
foo: 'foo',
bar: 'bar'
};
And I have a function:
var f = function(bar, foo) {
// Do something with bar and foo
};
Is there a way I can dynamically call the function using the object, so that obj['foo'] is passed as the 'foo' parameter, and obj['bar'] is passed as the 'bar' parameter? Note that I may not know the actual names of the keys and values or the function argument names, the ones provided are just an example, so f.call(this, obj['bar'], obj['foo']);
won't do.