Home >Web Front-end >JS Tutorial >Do Arrow Functions in ES6 Have Access to Arguments Objects?
Official Documentation on Arguments in ES6 Arrow Functions
In the realm of ES6, arrow functions have sparked a debate regarding their treatment of the arguments keyword. Contrary to early TC39 recommendations, browser engines such as Chrome, Firefox, and Node.js seem to allow arrow functions to access the arguments object.
However, Babel, a popular JavaScript transpiler, follows the initial TC39 stance and disallows this behavior. This inconsistency has left developers seeking official documentation to resolve the ambiguity.
According to the [ECMAScript 2015 Language Specification](https://www.ecma-international.org/ecma-262/6.0/#sec-arrow-function-definitions), arrow functions do not have their own arguments binding. When calling an arrow function, no arguments object is created.
Specifically, the specification states:
Based on these official documents, it is clear that Babel's behavior is correct and arrow functions should not have access to the arguments object within their scope.
The above is the detailed content of Do Arrow Functions in ES6 Have Access to Arguments Objects?. For more information, please follow other related articles on the PHP Chinese website!