Chapter 3. Functions are fundamental

 

In this chapter we discuss

  • Why understanding functions is so crucial
  • How functions are first-class objects
  • How the browser invokes functions
  • Declaring functions
  • The secrets of how parameters are assigned
  • The context within a function

You might have been somewhat surprised, upon turning to this part of the book dedicated to JavaScript fundamentals, to see that the first topic of discussion is to be functions rather than objects.

We’ll certainly be paying plenty of attention to objects (particularly in chapter 6), but when it comes down to brass tacks, the main difference between writing JavaScript code like the average Joe (or Jill) and writing it like a JavaScript ninja is understanding JavaScript as a functional language. The level of the sophistication of all the code you’ll ever write in JavaScript hinges upon this realization.

If you’re reading this book, you’re not a rank beginner and we’re assuming that you know enough object fundamentals to get by for now (and we’ll be taking a look at more advanced object concepts in chapter 6), but really understanding functions in JavaScript is the single most important weapon you can wield. So important, in fact, that this and the following two chapters are going to be devoted to thoroughly understanding functions in JavaScript.

3.1. What’s with the functional difference?

3.2. Declarations

3.3. Invocations

3.4. Summary

sitemap