Why do arrow functions not have the arguments array? [duplicate]

Arrow functions don’t have this since the arguments array-like object was a workaround to begin with, which ES6 has solved with a rest parameter:

var bar = (...arguments) => console.log(arguments);

arguments is by no means reserved here but just chosen. You can call it whatever you’d like and it can be combined with normal parameters:

var test = (one, two, ...rest) => [one, two, rest];

You can even go the other way, illustrated by this fancy apply:

var fapply = (fun, args) => fun(...args);

Leave a Comment