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‘
原文:https://www.cnblogs.com/bbb324/p/11774066.html