js -- 箭頭函式和function關鍵字函式的小坑
阿新 • • 發佈:2018-12-15
var a = {
name : 'cd',
say : function(){
console.log(this.name)
}
}
a.say() // cd 正常輸出
var a = {
name : 'cd',
say : () => {
console.log(this.name) //這裡的this 是 {}
}
}
a.say() // undefined
