JS currying

by karthick Chandran

JavaScript

/* Curry Example 
Example 1  plain arrow function*/

var greet = (greeting, name) => (console.log(greeting + ", " + name))


/* Curry Example 
this is how curry works behind the scenes */
var greetCurried = function(greeting) {
  return function(name) {
    console.log(greeting + ", " + name);
  };
};

/*changed the above function to arrow */
var greetCurried2 = (greeting) => (name) => console.log(greeting + ", " + name);

var initFirst = greetCurried2('Hola.. ')

initFirst('Karthick..Zoro')




/*This is not chicken curry ----  Another example */
var mycurryMuliple = (a) => (b) => (c) => console.log(a + b + c);

/*initing  the seecond part*/
var second = mycurryMuliple(1);

/*calling second with nth param*/
second(2)(3);



  var lvl1 = (a) => (b) => console.log(a + b)
var lvl2 = lvl1('Karthick');

lvl2('HI')