Wsy 这个箭头函数不适用于 'arguments.length'?

Wsy this arrow function doesn't work with 'arguments.length'?

我想知道为什么下面这个名为 'countArg2' 的箭头函数不起作用。 有没有人可以解释一下哪里出了问题?


这有效
function countArg1() {
    return arguments.length;
}
countArg1(1, 2, 3);   //3

这行不通..
const countArg2 = () => arguments.length;
countArg2(1, 2, 3);
 // VM6745:1 Uncaught ReferenceError: arguments is not defined

提前致谢。

你必须像这样解析箭头函数的参数

const countArg2 = (...arguments) => arguments.length;
console.log(countArg2(1, 2, 3));
 // VM6745:1 Uncaught ReferenceError: arguments is not defined
 // at mArgs (<anonymous>:1:29)
 // at <anonymous>:2:1