9. Closures

In This Chapter

  • Understand what closures are

  • Tie together everything you’ve learned about functions, variables, and scope

By now, you probably know all about functions and all the fun functiony things that they do. An important part of working with functions, with JavaScript, and (possibly) life in general is understanding the topic known as closures. Closures touch upon a gray area where functions and variable scope intersect (Figure 9.1).

Image

FIGURE 9.1

Closures.

Now, I am not going to say any more about closures, for this is something best explained by seeing code. Any words I add right now to define or describe what closures ...

Get JavaScript Absolute Beginner's Guide, 2nd 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.