5 First-class functions for the novice: definitions and arguments
This chapter covers
- The ways to define a function
- What makes JavaScript functions so powerful
- How TypeScript can catch bad function calls before they happen
Upon turning to this part of the book dedicated to JavaScript fundamentals, you might be surprised to see that the first topic of discussion is functions rather than objects. We’ll certainly be paying plenty of attention to objects in part 3 of the book, but when it comes down to brass tacks, the main difference between writing JavaScript code like the average Jill (or Joe) and writing it like a JavaScript ninja is understanding JavaScript as a functional language. The level of sophistication of all the code you’ll ever write in JavaScript hinges on this realization.
If you’re reading this book, you’re not a rank beginner. We’re assuming that you know enough object fundamentals to get by (and we’ll be taking a look at more advanced object concepts in chapter 9), but really understanding functions in JavaScript is the single most important weapon you can wield. So important, in fact, that this and the following three chapters are devoted to thoroughly understanding functions in JavaScript.