liveBook · Manning

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.

How 2 Manning books explain it

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

What to know first

Related concepts

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.