Function.call()

JavaScript 1.3+, JScript 1.0+ Nav4.06+, IE 3+, Opera3+ Syntax

							function.call(this)

function.call(this, arg1, arg2, …, argN)

Description

The call() method of the Function object allows you to call another object's method. Optional arguments can be passed to the method as shown in the second syntactical definition.

Example

Listing 6.128 shows an example of the call() method. The script creates a person and author object. The author object uses the call() method to perform some of its creation.

Listing 6.128 Using the call() Method of the Function Object
 <script language="JavaScript1.3"> <!–– Hide // Create a person object to handle the creation // of people function person (author, name){ this.name = name; this.author = ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.