...
Util.js v0.5 and above.
Syntax
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
// create new function based on existing one with one or more pre-defined arguments var fNew = fExisting.uCurry(cArgs); // use the new function optionally specifying additional arguments fNew(args); |
Where fExisting is any existing function.
...
Value | Type | Description | Util.js version |
---|---|---|---|
<fNew> | Function | A new function which will automatically set the cArgs arguments for fExisting and then append any additional arguments passed in to fNew. | 0.5 |
<fExisting> | Function | If you do not specify cArgs then the existing function will be returned. | 0.5 |
Example
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
function booler(not,a,b) { return (not) ? a!=b : a==b; } var isMe = booler.uCurry(false,me); // not == false, a = me isMe(7); // true if me == 7, false if me != 7 var isNotMe = booler.uCurry(true,me); isMe(7); // true if me != 7, false if me == 7 |
A good better example is shown in Object.uAddProperty() example using a curried allianceExistsBetween() function.
...