?
ES6+ 新特性, 是函数的新写法
use
const fn = (x, y) => {
return x + y
}
console.log(fn(1,2));
箭头函数的this指向
- 箭头函数的this值会指向它上一级的作用域(函数),直接定义箭头函数,它的this就直接指向window了, 注意在DOM事件的时候避免用箭头函数
ES6+ 新特性, 是函数的新写法
const fn = (x, y) => {
return x + y
}
console.log(fn(1,2));