The Hard Parts of Functional JavaScript

Partial Application Review

Will Sentance

Will Sentance

The Hard Parts of Functional JavaScript

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.


Transcript from the "Partial Application Review" Lesson

>> 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.

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.

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.

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.

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.

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.

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