SUMMARY
Functions are useful and versatile tools in JavaScript programming. ECMAScript 6 introduces powerful syntax allowing you to wield them even more effectively.
- Function expressions are different from function declarations. Function declarations require names, while function expressions do not. A function expression without a name is also called an anonymous function.
- New in ES6, arrow functions are similar to function expressions, but with some important differences.
- Arguments and parameters in JavaScript functions are highly flexible. The
arguments
object, along with the new spread operator in ES6, allow for totally dynamic definition and invocation. - Internally, functions expose a handful of objects and references that provide you information on how the function was invoked, where it was invoked, and what was originally passed to it.
- Engines will optimize functions with tail calls to preserve stack space.
- Behind the scenes, the closure's scope chain contains a variable object...