1.箭头函数作为匿名函数,不能作为构造函数,不能使用new
var B = ()=>{
value:1;
}
var b = new B(); //TypeError: B is not a constructor
2.箭头函数不绑定arguments,取而代之用rest参数…解决
function A(a){
console.log(arguments); //[object Arguments] {0: 1}
}
var B = (b)=>{
console.log(arguments); //ReferenceError: arguments is not defined
}
var C = (...c)=>{ //...c即为rest参数
console.log(c); //[3]
}
A(1);
B(2);
C(3);
3.箭头函数会捕获上下文this作为自己的this,this继承自外围作用域。在箭头函数中调用 this 时,仅仅是简单的沿着作用域链向上寻找,找到最近的一个 this 拿来使用。
4.箭头函数没有原型属性。
5.箭头函数无法换行。