this指向问题
来源:16-4 作用域和闭包-this-代码演示
派大星_
2019-09-18
function Foo(name){
this.name = name
this.sayHi = function () {
console.log(this)
}
}
var f = new Foo(‘zhangsan’)
f.sayHi()
老师,这里this的指向不是应该是f吗,为什么this指向了Foo
写回答
1回答
-
是指向 f 啊,不是 Foo 。这个代码运行应该没啥问题呀。
00
相似问题