apply with function javascript code example
Example 1: apply() js
The apply() method accepts arguments in an array:
var arr = [6, 89, 3, 45];
var maximus = Math.max.apply(null, arr); // returns 89
Example 2: javascript apply
function myFunc(p1, p2, pN)
{
// here "this" equals myThis
}
let myThis = {};
// call myFunc using myThis as context.
// destructure array to function arguments.
myFunc.apply(myThis, ["param1", "param2", "paramN"]);