Understanding ECMAScript 6：
new.targetbindings - The value of
new.targetinside of the function is by the closest containing nonarrow function. (
superis covered in Chapter 4.)
- Cannot be called with
new- Arrow functions do not have a
[[Construct]]method and therefore cannot be used as constructors. Arrow functions throw an error when used with
- No prototype - since you can't use
newon an arrow function, there's no need for a prototype. The
prototypeproperty of an arrow function doesn't exist.
- Can't change
this- The value of
thisinside of the function can't be changed. It remains the same throughout the entire lifecycle of the function.
argumentsobject - Since arrow functions have no
argumentsbinding, you must rely on named and rest parameters to access function arguments.
- No duplicate named parameters - arrow functions cannot have duplicate named parameters in strict or nonstrict mode, as opposed to nonarrow functions that cannot have duplicate named parameters only in strict mode.
There are a few reasons for these differences. First and foremost,
this value inside a function, which can result in unintended program behavior, and arrow functions eliminate this confusion. Second, by limiting arrow functions to simply executing code with a single
Note: Arrow functions also have a
nameproperty that follows the same rule as other functions.