Chapter 5. Functions for the master: closures and scopes
This chapter covers
- Using closures to simplify development
- Tracking the execution of JavaScript programs with execution contexts
- Tracking variable scopes with lexical environments
- Understanding types of variables
- Exploring how closures work
Closely tied to the functions we learned about in previous chapters, closures are a defining feature of JavaScript. Although scores of JavaScript developers can write code without understanding the benefits of closures, their use can not only help us reduce the amount and complexity of code needed to add advanced features, but also enable us to do things that otherwise wouldn’t be possible, or would be too complex to be feasible. For example, any ...
Get Secrets of the JavaScript Ninja, Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.