If you want to force a particular function implementation to be used on an object, you can locate the one you want and pass it an object on which to operate. The function then executes as if it were a property of the passed object instead of the receiving object.
This can be useful to restore some functionality that may have been overridden or to share a function definition between several objects.
This is effectively like adding the function as a property to the target object, executing it, passing the arguments to it and then deleting the function property afterwards. Applying a function is a lot easier.
This is similar to the apply() method which passed the arguments as an array. This passes them as a comma separated list.
// Call this function against another object myFunctionObject.call(myTargetObject, 100, "aaa");
See also: | Event handler scope |
Prev | Home | Next |
Function.arity | Up | Function.caller |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |