JavaScript Arrow Functions Arguments Object


Example

Arrow functions do not expose an arguments object; therefore, arguments would simply refer to a variable in the current scope.

const arguments = [true];
const foo = x => console.log(arguments[0]);

foo(false); // -> true

Due to this, arrow functions are also not aware of their caller/callee.

While the lack of an arguments object can be a limitation in some edge cases, rest parameters are generally a suitable alternative.

const arguments = [true];
const foo = (...arguments) => console.log(arguments[0]);

foo(false); // -> false