How to convert array to sequence of function args in javascript?
Answers
Answered by
0
Is it possible to convert an array in JavaScript into a function argument sequence? Example:
run({ "render": [ 10, 20, 200, 200 ] }); function run(calls) { var app = .... // app is retrieved from storage for (func in calls) { // What should happen in the next line? var args = ....(calls[func]); app[func](args); // This is equivalent to app.render(10, 20, 200, 200); } }
run({ "render": [ 10, 20, 200, 200 ] }); function run(calls) { var app = .... // app is retrieved from storage for (func in calls) { // What should happen in the next line? var args = ....(calls[func]); app[func](args); // This is equivalent to app.render(10, 20, 200, 200); } }
Similar questions