New Function Features

T.J. Crowder · 2020

This chapter discusses many of the exciting new features of functions in modern JavaScript, such as arrow functions, default parameter values, rest parameters, trailing commas in parameter lists and function calls, the function name property, and function declarations inside blocks. ES2015 added arrow functions to JavaScript. Arrow functions solve a whole class of problems, particularly with callback. The default expression is evaluated when the function is called, not when the function is defined, and only if the default is needed for that particular call to the function. Rest parameters providing true arrays of the “rest” of the arguments to a function after the named ones. ES2017 makes it possible to have a trailing comma at the end of parameter lists and argument lists. As of ES2015, function declarations in blocks are part of the specification. There are standard rules for them, and also “legacy web semantics” that only apply in loose mode on web browsers.

Read the paper · More papers on PaperTik