liveBook · Manning

Call

Function.prototype.call is a JavaScript method that invokes a function with a specified this value and arguments supplied individually.

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 individually.

How it is used
Controls a function’s execution context and supplies its arguments individually, including during callback invocation.
How deep it goes
Demonstrates explicit contexts through function calls and callbacks, contrasting positional arguments with apply’s array.
Examples
Uses a juggle function to set object results and a forEach callback to make each item its context.
What you can do after
Apply call to choose a callback’s this value and pass its arguments individually.

Read how Secrets of the JavaScript Ninja, Second Edition explains call →

Secrets of the JavaScript Ninja, Third Edition

A JavaScript method that invokes a function with an explicitly supplied this value and individual arguments.

How it is used
Invokes a function with an explicitly chosen context, including when borrowing a method for another object.
How deep it goes
Defines the context-first syntax and individual argument list, contrasting call with apply without detailing implementation internals.
Examples
Demonstrates a sum function writing results to two objects and contrasts individual call arguments with apply’s array.
What you can do after
Apply call to invoke a function with a chosen context and individually supplied arguments.

Read how Secrets of the JavaScript Ninja, Third Edition explains call →

Also covered in

What to know first

Related concepts

Questions about call

What is call?

Function.prototype.call is a JavaScript method that invokes a function with a specified this value and arguments supplied individually.

Which Manning books explain call?

Secrets of the JavaScript Ninja, Second Edition and Secrets of the JavaScript Ninja, Third Edition.

What should I know before learning call?

Manning books that teach call usually introduce function, new keyword, strict mode and this first.

What is the difference between call and apply?

Function.prototype.call is a JavaScript method that invokes a function with a specified this value and arguments supplied individually. 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.

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.