A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/javascript/what-is-currying-function-in-javascript/ below:

Currying Function in JavaScript - GeeksforGeeks

Currying Function in JavaScript

Last Updated : 10 Aug, 2025

Currying is used in JavaScript to break down complex function calls into smaller, more manageable steps. It transforms a function with multiple arguments into a series of functions, each taking a single argument.

JavaScript
// Normal Function
// function add(a, b) {
//     return a + b;
// }
// console.log(add(2, 3)); 

// Function Currying
function add(a) {
    return function(b) {
        return a + b;
    }
}

const addTwo = add(5);  // First function call with 5
console.log(addTwo(4));  

In this example

How Currying Works in JavaScript?

Currying function in the JavaScript can be done manually, but it can also be done using the closure. Below it is shown that how currying function works.

Currying with Arrow Functions

Arrow function can be used to make currying function short:

JavaScript
const add = a => b => a + b;
console.log(add(5)(4));  

This syntax is shorter and doining the same thing as the earlier example.

When to Use Currying in JavaScript?

In JavaScript, currying function is used in the following cases:


What is currying function in JavaScript ?


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4