Unit 3. Functions
Functions are a pretty fundamental construct for authoring applications. This is especially true in a language like JavaScript, which treats functions as first-class citizens. With ES2015 and later, many awesome features have been added to functions, including several completely new types of functions.
We’ll start the unit by taking a look at default parameters and rest. I think most programmers, at some point, have had the need for default parameters and likely worked around it by checking for a value and assigning one if undefined at the start of the function. The rest param is even more useful. Anyone who has used the arguments object before will be happy to use rest. Not only does rest render the arguments object obsolete, it allows you to combine it with other arguments, rather than always acting like a catchall as the arguments object does.
We’ll then take a dive into destructuring function arguments, which can also be combined with default parameters. When you put these all together, you can make some pretty powerful function declarations. You can even simulate named parameters. So, no more passing null values to a function like myFunc(null, null, 5), because you only need to specify the third argument (or fourth, fifth, and so on).