From the course: Learning Functional Programming with JavaScript (ES5)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Partial application

Partial application - JavaScript Tutorial

From the course: Learning Functional Programming with JavaScript (ES5)

Start my 1-month free trial

Partial application

- [Narrator] First we'll talk about partial application. Now what partial application is is this. Let's say that we have a function with a certain number of arguments. What partial application is is taking one of those arguments and fixing the value. This gives us a function with one less argument. We can then call this function and it will call our original function with both the argument that we fixed and the new argument that we pass in. Let's change this example around a little bit so that we can get a better idea of how this works. So, what if instead of having an add function that takes only two arguments, we had one that took three? If we wanted to partially apply only the first argument, we could change it like this. Notice that now when we call partiallyApply, we get a function that takes two arguments. These two arguments represent the last two arguments of our add function. Now we can call add5 with another argument. Notice that this gives us exactly the same result as if…

Contents