在命名箭头函数中与 arguments.length 混淆

confused with arguments.length in a named arrow function

我试图使用 arguments.length:

获取 命名函数 的长度
var a = function(b,c){
console.log(arguments.length);
};
a(1,2); //2 (this is what I'm expecting)


(function(b,c){
console.log(arguments.length);
})(1,2); //it returns 2 also


(b,c) => {
console.log(arguments.length);
};
(1,2); //2 also

但是当我尝试使用命名箭头函数时:

let a = (b,c) => {
console.log(arguments.length);
};
a(1,2); //ReferenceError: arguments is not defined

还有这个:

((b,c) => {
console.log(arguments.length);
})(1,2); //ReferenceError: arguments is not defined

我现在很迷茫

Arrow functions do not bind the arguments magic variable. 你的第一个测试完全错了;表达式 (1,2) 的 return 值为 2,但这只是因为 2, 运算符的最后一个操作数,而不是因为 arguments.length. "anonymous arrow function" 在该示例中甚至没有被调用。