Partial application

A very important FP technique is also amongst the ES2020 proposals: partial application. As mentioned earlier, this FP technique makes it possible to fix a number of arguments to a function by producing a new dynamically generated function with less arity. Here is a simple code example:

function add(num1, num2) {    return num1 + num2;}function add1(num2) {    return add(1, num2);}

The ES2020 proposal suggests that partial application could be performed as follows:

const add = (x, y) => x + yconst add1 = add(?, 1)

Of course, we could mention many other FP techniques that could find their way into the ES2020 specifications, such as function binding, currying and pattern matching, but what one must know is that JavaScript is increasingly ...

Get Mastering The Faster Web with PHP, MySQL, and JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.