Calling Dynamic Functions with Dynamic Paramters
Useful for wrapper APIs or communicating with external interfaces:
function callFunction(fn) {
this[fn].apply(this, Array.prototype.slice.call(arguments, 1));
}
callFunction("alert", "It works");
callFunction("setTimeout", function() {
alert("Timeout after 5s");
}, 5000);