Chapter 5
Harnessing the Power of Functions
IN THIS CHAPTER
Getting to know JavaScript functions
Creating and using custom functions
Passing and returning function values
Working with anonymous and arrow functions
Getting to the bottom of variable scope
Understanding recursive functions
To iterate is human, to recurse divine.
— L. PETER DEUTSCH
As I demonstrate throughout this book, JavaScript comes with a huge number of built-in features that perform specific tasks. For example, something called the Math object has a built-in method for calculating the square root of a number. Similarly, a feature called the String object has a ready-made method for converting a string value to all lowercase letters.
Hundreds of these ready-to-roll features perform tasks that range from the indispensable to the obscure. But JavaScript can't possibly do everything that you’d like or need it to do. ...