Suggest an editImprove this articleRefine the answer for “Partial application”. Your changes go to moderation before they’re published.Approval requiredContentWhat you’re changing🇺🇸EN🇺🇦UAPreviewTitle (EN)Short answer (EN)**Partial application** is a technique in which a function is not called with all its arguments at once: part of the arguments is "remembered", and a new function is returned that waits for the rest. Unlike currying, which takes arguments one at a time, partial application lets you fix several at once. **Key point:** a typical example is `fn.bind(null, arg1)`, which returns a new function with an argument already substituted in.Shown above the full answer for quick recall.Answer (EN)Image**In short:** **Partial application** is a technique in which a function is called **not with all its arguments at once**; instead, **part of the arguments is "remembered"**, and a **new function** is returned that waits for the remaining arguments. --- ### Detailed explanation > The idea: "fix" part of a function's parameters > to get a new, more specific function. Unlike **currying**, where a function takes **one argument at a time**, partial application lets you pass **several at once**. --- ### Example 1 - a simple implementation ```javascript function multiply(a, b, c) { return a * b * c; } // Partially apply: fix a = 2 function partialMultiply(a) { return function(b, c) { return multiply(a, b, c); }; } const double = partialMultiply(2); console.log(double(3, 4)); // 24 ``` We "fixed" the first argument (`a = 2`) and got a new function, `double`. --- ### Example 2 - with `bind()` JavaScript already lets you do partial application using `Function.prototype.bind`: ```javascript function add(a, b, c) { return a + b + c; } const add5 = add.bind(null, 5); // fix a = 5 console.log(add5(10, 20)); // 35 ``` `bind` creates a new function with the arguments already substituted in. --- ### Example 3 - a universal partial function ```javascript function partial(fn, ...fixedArgs) { return (...remainingArgs) => fn(...fixedArgs, ...remainingArgs); } function greet(greeting, name) { return `${greeting}, ${name}!`; } const sayHi = partial(greet, 'Hello'); console.log(sayHi('Alice')); // "Hello, Alice!" ``` --- ### Difference from currying | Technique | What it does | |---|---| | **Currying** | Transforms a function with several arguments into a chain of one-argument functions (`f(a)(b)(c)`) | | **Partial application** | Substitutes part of the arguments and returns a new function (`f(a, b, c)` -> `g(b, c)`) | --- ### Why partial application is needed Reusing functions with different contexts Simplifying calls and configurations Improving readability Often used in **functional programming**, **React** and **middleware** --- ### Summary | Property | Partial application | |---|---| | Essence | "Remembers" part of the arguments | | Returns | A new function | | Example | `add.bind(null, 5)` or `partial(add, 5)` | | Difference from currying | Accepts several arguments at once | | Benefit | Code reuse and simplification |For the reviewerNote to the moderator (optional)Visible only to the moderator. Helps review go faster.