From the course: Learning Functional Programming with JavaScript ES6+
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Currying and partial application - JavaScript Tutorial
From the course: Learning Functional Programming with JavaScript ES6+
Currying and partial application
- The first advanced concept we're going to look at is called partial application. In simple terms, partial application is when we take a function that has some number of arguments, and we fix some of those arguments to a set value. This gives us a function with less arguments than we had before. This function with fixed arguments can then be called from anywhere else in code, and it will be as if we had called the original function with all of its arguments. Partial application is a very useful way to configure more general functions into more specific ones. In general, if there's a function that we use often in our code, where one or more of the arguments that we call it with is almost always the same, this is a good candidate for using partial application. So now that we know what partial application is, what does it look like in code? Well let's imagine that we have a simple add function. Const add, and it takes three arguments we'll call them X, Y, and Z, and adds them together…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.