call() and apply() javascript code example
Example 1: javascript function call with variable
function abc() {
alert('test');
}
var funcName = 'abc';
window[funcName]();
Example 2: call function javascript
// Define your function
function sayHello(msg){
console.log("Hello, " + msg);
}
// Call it
sayHello("Norris");
// outputs:
// Hello, Norris
Example 3: js call and apply
func.call([thisArg[, arg1, arg2, ...argN]])