【发布时间】:2017-11-13 16:06:23
【问题描述】:
我试图使用 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
我现在真的很困惑
【问题讨论】:
标签: javascript ecmascript-6 arguments arrow-functions