Chapter 2. Reintroducing JavaScript
This chapter covers
- Variable scoping, function hoisting, and the execution context object
- Explaining variable scope chains and why we use them
- Creating JavaScript objects using prototypes
- Writing self-executing anonymous functions
- Using the module pattern and private variables
- Exploiting closures for fun and profit
This chapter reviews unique JavaScript concepts that we need to know if we’re to build a native JavaScript single page application of significant scale. The snippet of code in listing 2.1 from chapter 1 shows the concepts we’ll be covering. If you understand all of these how and why concepts then you might skim or skip this chapter and get straight to work on an SPA in chapter 3.
To follow along at home you can cut and paste all of the listings in this chapter into the console log of Chrome Development Tools and press Return to see them execute. We highly encourage you to join in the fun.