【发布时间】:2014-12-05 06:49:14
【问题描述】:
在外部函数中,this.foo 是 bar,这正是我所期望的。但是,在内部函数中,this.foo 是未定义的,这非常令人惊讶。有人可以帮我吗?谢谢。
var myObject = {
foo: "bar",
func: function () {
console.log("outer func: this.foo = " + this.foo);
(function () {
console.log("inner func: this.foo = " + this.foo);
}());
}
};
myObject.func();
【问题讨论】:
标签: javascript