Function.prototype.apply

Calls the function, substituting the specified object for the this value of the function, and the specified array for the arguments of the function.

Syntax

apply(thisArg, args?)

Parameters

Return value

The result of calling the function.

Examples

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"]