Secrets of the JavaScript Ninja: Chapter 3 Review

Functions are Fundamental

The concept of functions as first-class objects is central to this chapter, as it is the foundation of the rest of the book. It is this fact that allows them to be treated as variables, objects, and classes. It also covers the five ways to call a function (function, method, constructor, call, and apply) and what each means in terms of arguments and scope.

What I Learned in This Chapter:

There was something here that I knew intuitively, but not with succinct consciousness until this book spelled it out plainly. A function invoked as a function is always in the window scope:

In both of the above cases, the functions will run in the window context, regardless of where they were defined or called. Scope/context are one of the most important things to understand in JavaScript, so a clearer understanding is a better understanding.