Javascript Notes part-3 (Execution Context,Event Loop)
Currying Currying simply means evaluating functions with multiple arguments and decomposing them into a sequence of functions with a single argument. In other terms, currying is when a function ,instead of taking all arguments at one time, takes the first one and returns a new function, which takes the second one and returns a new function, which takes the third one, etc. until all arguments are completed. // Noncurried version const add = ( a , b , c ) => { return a + b + c ; }; console. log ( add ( 2 , 3 , 5 )); // 10 // Curried version const addCurry = ( a ) => { return ( b ) => { return ( c ) => { return a + b + c ; }; }; }; console. log ( addCurry ( 2 )( 3 )( 5 )); // 10 There are several reasons why currying is ideal: Currying is a checking method to make sure that you get everything you need before you proceed It helps you to avoid passing the same variable again and agai...