Apply
Function.prototype.apply is a JavaScript method that invokes a function with a specified this value and arguments supplied as an array or array-like object.
Secrets of the JavaScript Ninja, Second Edition
A JavaScript Function method that invokes a function with an explicit this value and arguments supplied as an array-like object.
- How it is used
- Uses apply to invoke a function with an explicit context and an array of arguments.
- How deep it goes
- Explains apply’s context and argument parameters with a worked comparison to call.
- Examples
- Demonstrates apply with a juggle function and contrasts it with call using separate objects.
- What you can do after
- Apply it to invoke a function with a chosen context and arguments supplied as an array.
Read how Secrets of the JavaScript Ninja, Second Edition explains apply →
Secrets of the JavaScript Ninja, Third Edition
A JavaScript method that invokes a function with an explicitly supplied this value and an array-like collection of arguments.
- How it is used
- Invokes a function with a chosen this value and an array of argument values.
- How deep it goes
- Explains context and argument passing, compares call, and notes spread as a modern alternative.
- Examples
- Demonstrates method borrowing with a summing function and contrasts apply with call.
- What you can do after
- Apply apply to invoke a function with a chosen context and array-supplied arguments.
Read how Secrets of the JavaScript Ninja, Third Edition explains apply →
Also covered in
- Spring AI in Action
- Build a Frontend Web Framework (From Scratch)
- JavaScript in DepthIn early access (MEAP)
What to know first
- arrow functionAn arrow function is a JavaScript function expression written with arrow syntax that uses lexical binding for this and has no own arguments object.
- functionA function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- new keywordIn JavaScript, new is an operator that creates an object instance by invoking a constructable function or class as its constructor.
- strict modeStrict mode is a JavaScript execution mode that applies stricter parsing and runtime rules and restricts or reports certain error-prone behaviors.
Related concepts
- callcontrasts with · Function.prototype.call is a JavaScript method that invokes a function with a specified this value and arguments supplied individually.
- thisconfigures · In JavaScript, the this value is determined by a function’s call context or, for an arrow function, inherited lexically.
- functionpart of · A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- spread operatoralternative to · A spread operator is syntax that unpacks a collection’s elements or an object’s properties into individual values within an expression or function call.
Questions about apply
What is apply?
Function.prototype.apply is a JavaScript method that invokes a function with a specified this value and arguments supplied as an array or array-like object.
Which Manning books explain apply?
Secrets of the JavaScript Ninja, Second Edition and Secrets of the JavaScript Ninja, Third Edition.
What should I know before learning apply?
Manning books that teach apply usually introduce arrow function, function, new keyword and strict mode first.
What is the difference between apply and call?
Function.prototype.apply is a JavaScript method that invokes a function with a specified this value and arguments supplied as an array or array-like object. Function.prototype.call is a JavaScript method that invokes a function with a specified this value and arguments supplied individually.
What is apply part of?
Apply is part of function. A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

