Standard built-ins

Function.prototype.apply()

Try the free JavaScript compiler

Calls a function with an explicit this and an array-like list of arguments. A nullish list supplies no arguments; a non-object non-nullish list is invalid.

Formal Syntax & Structure

javascript syntaxjavascript
fn.apply(thisArg, [argsArray])

Parameters & Attributes

NameTypeDescription
thisArgAnyReceiver supplied to target; the target controls this handling.
argsArrayObject | null | undefinedArray-like list or nullish empty list.

Return Value

Any

Target return value.

Working Example

Example Snippetjavascript
function f(a,b){return this.n+a+b;}console.log(f.apply({n:1},{0:2,1:3,length:2}));
JavaScript Reference