views:

45

answers:

2

Does YUI3 library have currying functionality ?

A: 

You can use Currying within Javascript and YUI3 is Javascript and CSS so yes, you can use Currying within YUI3.

Frankie
Yeah, I have my own currying function. I'm not sure if there is already a way to do currying within YUI3, to avoid repeating code.
Rogeliorv
@user437445 afaik there isn't. Even looked it up in the docs and found nothing. Guess it's just not mainstream methodology! ;)
Frankie
+1  A: 

Currying is done using the bind method provided by the oop module.

var add3 = Y.bind(function (a, b) { return a + b; }, null, 3);
console.log(add3(39)); // prints 42
lawnsea
Thanks, Y.bind seems to be the way to go. I have my own implementation, but using this is definitely better.
Rogeliorv