同学你好,根据上下文规则2:以圆括号的形式调用函数,则函数的上下文(this)是window对象。
这段代码中,fn是以圆括号的形式调用的,即:fn(),所以函数fn中的this指向window,如图

所以,this.a和this.b表示window对象中的属性a和属性b,而不是obj1对象中的属性a和属性b。
又因为在全局作用域中定义了变量a和变量b,在全局作用域中定义的变量会默认为window对象的属性,如图

因此,综上可得:this.a = 3,this.b = 4,相加得7,如图

祝学习愉快!
恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星