Partial Application

suggest change

Similar to currying, partial application is used to reduce the number of arguments passed to a function. Unlike currying, the number need not go down by one.

Example:

This function:

function multiplyThenAdd(a, b, c) {
    return a * b + c;
}

… can be used to create another function that will always multiply by 2 and then add 10 to the passed value;

function reversedMultiplyThenAdd(c, b, a) {
    return a * b + c;
}

function factory(b, c) {
    return reversedMultiplyThenAdd.bind(null, c, b);
}

var multiplyTwoThenAddTen = factory(2, 10);
multiplyTwoThenAddTen(10); // 30

The “application” part of partial application simply means fixing parameters of a function.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Functions:
* Syntax
* Partial Application

Table Of Contents
11 Arrays
12 Objects
14 Classes
16 Map
17 Set
24 Loops
25 Functions
27 Date
29 Scope
30 AJAX
35 Cookies
41 JSON
44 Fetch
45 Modules
46 Screen
64 Console
68 Symbols
73 Modals
76 Events
86 Proxy
89 WeakMap
90 WeakSet
102 Tilde