Function

Moduleejs
Definition class Function
InheritanceFunction inherit Object
StabilityEvolving.

The Function type is used to represent functions, function expressions, closures and class methods.

It contains a reference to the code to execute, the execution scope and possibly a bound "this" reference.


Properties

QualifiersPropertyTypeDescription
get boundObjectThe bound object representing the "this" object for the function. Will be set to null if no object is bound. Use bind() to set the bound "this" object.
get lengthNumbernull
get nameStringThe name of the function. Function expressions do not have a name and set the name property to the empty string.

Function Class Methods

(No own class methods defined)

QualifiersMethod

Function Instance Methods

QualifiersMethod
Function(args: Array)
 Create a function from the supplied formal parameter names and function body expression.
apply(thisObject: Object, args: Array): Object
 Invoke the function on another object.
bind(thisObj: Object, args: Array): Void
 Bind the value of "this" for the function.
call(thisObject: Object, args: Array): Object
 Invoke the function on another object.

Method Detail

Function(args: Array)
Description
Create a function from the supplied formal parameter names and function body expression.
Parameters
args: Array The parameters and body are suplied as discrete parameters to Function(), i.e. not as an array of args. Function ([args, ...], body).

apply(thisObject: Object, args: Array): Object
Description
Invoke the function on another object.
Parameters
thisObject: Object The object to set as the "this" object when the function is called.
args: Array Array of actual parameters to the function.
Returns
Any object returned as a result of applying the function.
Throws
ReferenceError: If the function cannot be applied to this object. H

bind(thisObj: Object, args: Array): Void
Description
Bind the value of "this" for the function. This can set the value of "this" for the function. If overwrite is false, it will only define the value of "this" if it is not already defined. Use bound to examine the bound "this" value.
Parameters
thisObj: Object Value of "this" to define.
args: Array Function arguments to supply to the function. These arguments preceed any caller supplied arguments when the function is actually invoked.

call(thisObject: Object, args: Array): Object
Description
Invoke the function on another object. This function takes the "this" parameter and then a variable number of actual parameters to pass to the function.
Parameters
thisObject: Object The object to set as the "this" object when the function is called.
args: Array Actual parameters to the function.
Returns
Any object returned as a result of applying the function.
Throws
ReferenceError: If the function cannot be applied to this object.