This lesson teaches you how arguments passed to a curried function allow us to store data in closure to be reused in our programs and applications. Since each argument, except for the final one, returns a new function, we can easily create reusable functions by supplying some of these arguments beforehand, and sharing these partially applied functions with other parts of our codebase. In this lesson, we'll create a curried function to fetch requests from an API that uses partial application to create reusable functionality.
i think you missed fat arrow in "Transcript" at every 'cb' .
const getFromAPI = baseURL => endpoint => cb
const getFromAPI = baseURL => endpoint => cb =>
Curring: const add = x => y => z => x + y + z; Partial Application: const add = x => (y, z) => x + y + z; right?
@Xu, no, not really. Partial application means that you have supplied values for the arguments (but not so many that you've triggered the final argument and the evaluation of the function).
// Your curried add function for three values const add = x => y => z => x + y + z // Partially apply first value const add10 = add(10) // returns y => z => 10 + y + z // Partially apply the second value const add25 = add10(15) // returns z => 10 + 15 + z // By passing in the final argument, the last function is called and we get the result const fortyFive = add25(20) // returns 10 + 15 + 20 === 45