Tasty JavaScript Curry

JavaScript Curry: A useful technique to partially evaluate functions. Coming Soon... function myFunc(a, b) { if (arguments.length < 1) { return myFunc; } else if (arguments.length < 2) { return function(c) { return a + c } } else { return a + b; } } console.log(myFunc(2,2)); var add4 = myFunc(4); console.log(add4); console.log(add4(5)); var add... Continue Reading →

Advertisements

Create a free website or blog at WordPress.com.

Up ↑