Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function.
apply(thisArg, args?)
thisArg
The object to be used as the this object.
args
An array of arguments to be passed to the function.
The result of calling the function.
function sum(a, b) {
return a + b
}
sum.apply(null, [1, 2])
3
let slice = Array.prototype.slice
let arr = ["one", "two", "three"]
slice.apply(arr, [0, 1])
["one"]