1, this: 永遠指向調用該方法的對象
1 function a() { 2 var name = 'white'; 3 console.log(this.name) 4 } 5 6 var b = { 7 name: 'yellow', 8 detail: function() { 9 console.log(this.name) 10 }, 11 } 12 b.a = a; 13 14 console.log(b.a()) // 'yellow'
posted on 2019-10-31 21:51 bbb324 阅读(155) 评论(0) 编辑 收藏 举报