double arrow functions (curry + closure)

When working with es6 js, you’ll see arrow functions like this:

Let’s break it down and see what’s happening.

Let’s process from left to right.

We first have a temp variable add that takes on a function with parameter x and a return expression.

Then we see that the return expression is (y) => x + y, which is a function.
Hence, this usage is a curry function. We return a partial function for continual external use.

In our curry function, the y is a parameter.

Hence, we we combine the two, we get:

The es6 way: