1. 构造函数可以使用 new 生成实例

  2. 箭头函数没有自己的 this,它的 this 是继承函数所处上下文的 this,call、apply等无法改变 this 指向

1
2
3
4
5
6
7
8
9
10
11
let obj = {
name:'ov'
};
function fn1() {
console.log(this);
}
fn1.call(obj); // obj
let fn2 = ()=>{
console.log(this) // this是所属上下文,window
};
fn2.call(obj); //window
  1. 箭头函数没有 arguments 类数组,只能基于 …arg 获取传递的参数集合
1
2
3
4
let fn = () => {
console.log(arguments)
}
fn(10, 20, 30)
Uncaught ReferenceError: arguments is not defined
1
2
3
4
let fn = (...arg) => {
console.log(arg)
}
fn(10, 20, 30)

  [10, 20, 30]

  1. 箭头函数不能被 new 执行,没有 prototype 属性
1
2
3
4
let a = () => {}
let b = function(){}
dir(a)
dir(b)