1, this: 永遠指向調用該方法的對象
- function a() {
- var name = 'white';
- console.log(this.name)
- }
- var b = {
- name: 'yellow',
- detail: function() {
- console.log(this.name)
- },
- }
- b.a = a;
- console.log(b.a()) // 'yellow'
前端面試題
来源: http://www.bubuko.com/infodetail-3266935.html