function.call javascript code example
Example 1: javascript function call with variable
function abc() {
alert('test');
}
var funcName = 'abc';
window[funcName]();
Example 2: Functions call functions js
function sum (arr) {
let suma = 0;
for (let i = 0; i < arr.length; i++) {
let num= parseInt(arr[i]);
suma += num;
}
return suma;
}
function mean (arr) {
let average = sum(arr) /arr.length;
return average;
}
Example 3: call function javascript
function sayHello(msg){
console.log("Hello, " + msg);
}
sayHello("Norris");
Example 4: js call and apply
func.call([thisArg[, arg1, arg2, ...argN]])