By Anto Aravinth
What you'll Learn:
- Master useful programming concepts
- Understand real-world sensible libraries and create a sensible library that mimics underscore.js
- Perform pure-error dealing with strategies akin to functors and monads
- Discover ES6 practical gains reminiscent of unfold operators and generators
Who This e-book Is For:
Object-oriented programming is a well-liked buzzword nowadays. what's the explanation for this attractiveness? Is object-oriented programming the answer to the software program situation or is it only a fad? Is it an easy evolutionary step or an intensive switch in software program technique? what's the principal concept at the back of object-orien ted layout?
- Building Polyfills: Web Platform APIs for the Present and Future
Let’s get started! Chapter 3 ■ Higher-Order Functions ■■Note We will be creating few higher-order functions and adding it to our library. We are doing this for understanding how things work behind the scenes. The library is good for learning the current resources but they are not production ready for the library. So keep that in mind. :) Understanding Data As programmers we know our programs act on data. Data is something that is very important for the consumption of our written program to execute.
Later we will be moving to see more real-world examples of how HOC can help a programmer to solve complex problems easily. As before, we will be adding the HOC functions that we are creating in the chapter in our library. Let’s get started! Chapter 3 ■ Higher-Order Functions ■■Note We will be creating few higher-order functions and adding it to our library. We are doing this for understanding how things work behind the scenes. The library is good for learning the current resources but they are not production ready for the library.
The important point to note here is that we have declared a variable called done and set it to false initially. The returned function will have a closure scope over it; hence it will access it to check if done is true, if return undefined else set done to true (thus preventing next time execution) and calling the function with necessary arguments. 52 Chapter 4 ■ Closures and Higher-Order Functions ■■Note The apply function will allow us to set the context for the function and also pass on the arguments for the given function.