Currying in JavaScript
Trishank Sharma

Trishank Sharma @trishank_sharma_ac493a8f0

About: Full stack MERN developer

Joined:
Dec 27, 2024

Currying in JavaScript

Publish Date: Dec 27 '24
-1 0

Currying is the pattern of writing the functional code more modular. In simple words.

Currying is the pattern where a function with multiple arguments is transformed into a series of functions, each taking a single argument.

Instead of taking all arguments at once, the curried function takes the first argument, returns a new function that takes the next argument, and so on until all arguments are provided. The final function then returns the result.

//Normal Function
 `function nonCurrying(param1, param2, param3){
  return param1 + param2 + param3
}`

// Curried Function

`function curried(param1){
   return function(param2){
    return function(param3){
      return param1 * param2 * param3
}}}

curried(10)(20)(30);
`





Enter fullscreen mode Exit fullscreen mode

Comments 0 total

    Add comment