currying javascipt code example

Example 1: currying javascript

// It is also called nested function is ecmascript
const multiply = (a) => (b) => a*b;
multiply(3)(4); //Answer is 12

const multipleBy5 = multiply(5);
multipleBy5(10); //Answer is 50

Example 2: what is currying in javascript example

Uses of currying function
  a) It helps to avoid passing same variable again and again.

  b) It is extremely useful in event handling. 

syntax:

     function Myfunction(a) {
        return (b) => {
           return (c) => {
             return a * b * c
             }
            }
         }


myFunction(1)(2)(3);