Built-In Namespace Function
| Method Attributes | Method Name and Description |
|---|---|
|
bind(context)
Bind a function to an object and return it as a callback
|
|
|
bindAsEventListener(context)
Bind a function to an object and return it as a callback that recieves the active Event as its first argument
|
|
|
curry(1-n)
Create a callback with some arguments pre-specified
|
|
|
inherits(parentClass)
Makes a Class constructor Function inherit from another Class
|
Method Detail
{Function}
bind(context)
Bind a function to an object and return it as a callback
Defined in: function.js.
Defined in: function.js.
var myInstance = new MyClass(); var callback = myInstance.myMethod.bind(myInstance); //context-safe callback
- Parameters:
- {Object} context
- the object to bind the function to
- {arguments} 1..n Optional
- arguments to be passed to the function in the callback
- Returns:
- {Function} a callback to the function bound to the object
- Requires:
- Object#toArray
{Function}
bindAsEventListener(context)
Bind a function to an object and return it as a callback that recieves the active Event as its first argument
Defined in: function.js.
Defined in: function.js.
var myInstance = new MyClass(); var callback = myInstance.myMethod.bind(myInstance); //context-safe callback
- Parameters:
- {Object} context
- the object to bind the function to
- {arguments} 1..n Optional
- arguments to be passed to the function in the callback
- Returns:
- {Function} a callback to the function bound to the object
- See:
- Function#bind
{Function}
curry(1-n)
Create a callback with some arguments pre-specified
Defined in: function.js.
Defined in: function.js.
function myFunc(pre, text) {
return pre + text;
}
['car', 'house', 'dog'].map(myFunc.curry('Your')); // Returns ['Your car', 'Your house', 'Your dog']
- Parameters:
- {Mixed} 1-n
- the arguments to pre-apply to the callback
- Returns:
- {Function} the pre-applied callback
inherits(parentClass)
Makes a Class constructor Function inherit from another Class
Defined in: function.js.
Author: Shelby H. Moore III.
Defined in: function.js.
Author: Shelby H. Moore III.
function ClassA(arg) {
this.prop = arg || false;
}
ClassB.inherits(ClassA);
function ClassB(arg) {
this.inherits(ClassA);
this.prop2 = arg || 'default';
}
- Parameters:
- {Class} parentClass
- the Class to inherit from
- See:
- Object#inherits