repr(obj):
Return a programmer representation for obj. See the
Programmer Representation overview for more information about
this function.
- Availability:
- Available in MochiKit 1.3.1+
partial(func, arg[, ...]):
Return a partially applied function, e.g.:
addNumbers = function (a, b) {
return a + b;
}
addOne = partial(addNumbers, 1);
assert(addOne(2) == 3);
partial is a special form of bind that
does not alter the bound self (if any). It is equivalent to
calling:
bind(func, undefined, arg[, ...]);
See the documentation for bind for more details about
this facility.
This could be used to implement, but is NOT currying.
- Availability:
- Available in MochiKit 1.3.1+
bind(func, self[, arg, ...]):
Return a copy of func bound to self. This means whenever
and however the returned function is called, this will always
reference the given self. func may be either a function
object, or a string. If it is a string, then self[func] will
be used, making these two statements equivalent:
bind("method", self);
bind(self.method, self);
Calling bind(func, self) on an already bound function
will return a new function that is bound to the new self! If
self is undefined, then the previous self is used. If
self is null, then the this object is used (which may
or may not be the global object). To force binding to the global
object, you should pass it explicitly.
Additional arguments, if given, will be partially applied to the
function. These three expressions are equivalent and return
equally efficient functions (bind and
partial share the same code path):
- Availability:
- Available in MochiKit 1.3.1+