入坑ES6
入坑ES61. 箭头函数
1. 箭头函数
this 指向问题
const obj = {
name1: 'James 23',
getName: () => {
// this 指向window
console.log(this.name1)
},
getName2: function() {
// this 指向obj
console.log(this.name1)
},
getName3() {
// this 指向obj,等价
原创
2021-07-30 23:44:26 ·
68 阅读 ·
0 评论