JSClass.call

The JSClass.call and JSClass.construct hooks are called when a custom object is used like a function. These hooks are of type JSNative.

Note that when a custom object is called, a this argument is calculated for it just as if it were a function. That is, the obj argument received by the JSNative is the this argument, not the custom object that was called!

// Suppose this object has JSClass.call and JSClass.construct hooks.
var custom = new SpecialCustomObject();
custom();      // The JSClass.call hook receives the global object as the obj parameter.
new custom();  // The JSClass.construct hook receives the global object as the obj parameter.
var x = { specialMethod: custom };
x.specialMethod();      // The JSClass.call hook receives x as the obj parameter.
new x.specialMethod();  // The JSClass.construct hook receives x as the obj parameter.

The custom object that was called is JSVAL_TO_OBJECT(JS_ARGV_CALLEE(argv)).

See Also

Document Tags and Contributors

 Contributors to this page: arai, fscholz, Jorend
 Last updated by: arai,