Check out a free preview of the full The Hard Parts of Functional JavaScript course

The "Partial Application Review" Lesson is part of the full, The Hard Parts of Functional JavaScript course featured in this preview video. Here's what you'd learn in this lesson:

Will reviews partial application and its benefits, namely, easier to add features, readability and simplify the debugging process.

Preview
Close

Transcript from the "Partial Application Review" Lesson

[00:00:00]
>> Will Sentance: So, all of that work to adjust our function multiply here and reality will be adjusting functions. Like say we want to do a pen to a particular piece of specific text to DOM a element, for example, will be adjusting functions in practice much more usable the multiply.

[00:00:21]
To adjust it, to pre fill it with a value two, in practice that we might have to pre fill more than just one value of function. Many functions taken 3 4 5 inputs. We call it era t if you want to be fancy and sound sophisticated, the narrative five, and hold on.

[00:00:40]
We honor only taking one input to prefit it. Well, we have a technique to adjust any function that takes in many inputs, into a not a function that takes in many inputs, but a series of function calls each taking in an input one by one. This dollars and is currying we're not going to go into it in detail here, but it's a more generalized version of our partial application approach.

[00:01:08]
Partial application has allowed us to make it easier to add features. We're going to see in a moment, a practical example where we might have had to partially apply some of our data before we pass that function into our list of functions to run one by one by one by one automatically.

[00:01:25]
We can now, in this case, use the function multiply. We can write it once and then use it for different situations. But in practice, we could write out the more practicable functions once and then pre fill one of their arguments for many different situations. It makes it more readable.

[00:01:41]
When we can use functions that have multiple arguments in our list of functions style, we get a beautiful setup of readable code. We'll see it again in a moment, easy to debug. Now we can break application into individual units, even if those individual units actually need multiple inputs.

[00:02:02]
Now, no problem. Thanks to partial application and the help of Closure.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now