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 + y
const 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 becoming a functional language and that many future engine optimizations will automatically enhance overall performance of any executed code if it is written with FP principles in mind.

For further information on functional programming and functional JavaScript, please get one of the many good books and videos on these subjects that have been published by Packt Publishing in recent years.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset