1、this是静态的,this始终指向函数声明时所在作用域西安的this的值
javascript
function getName() {
console.log(this.name)
}
let getName2 = () => {
console.log(this.name)
}
window.name = 'a';
const shcool = {
name: 'b'
}
getName.call(school) // 'b'
getName2.call(school) // 'a'
2、不能作为构造函数实例化对象
3、不能使用arguments变量
4、箭头函数的简写
1)省略小括号,当形参有且只有一个的时候
javascript
let add = n => {
return n + n;
}
2)省略花括号,当代码体只有一条语句的时候,此时return必须省略。
javascript
let pow = (n) => n * n;