0
let args = () => {   
    console.log(arguments.length);
}; 
    args(2,4,5,6,72);

The above returns an error which says, "arguments is not defined."

However, ES5 syntax works are expected (see below):

var args = function() {
   console.log(arguments.length);
};
   args(2,4,5,6,72);

I would really appreciate an explanation and a remedy to this problem I have run into when using the ES6 syntax. Thanks.

  • Arrow functions don't have an arguments object, see [*ECMA-262 ยง9.2.12 FunctionDeclarationInstantiation*](http://ecma-international.org/ecma-262/7.0/index.html#sec-functiondeclarationinstantiation) note after item 18. โ€“ RobG Dec 29 '16 at 00:02
  • Related: [Arrow function vs function declaration / expressions: Are they equivalent / exchangeable?](http://stackoverflow.com/q/34361379/218196) (especially see information about variadic functions). โ€“ Felix Kling Dec 29 '16 at 00:15
  • Thank you Felix Kling - the are they equivalent question was helpful! โ€“ Anton Bredl Dec 29 '16 at 02:35

0 Answers0