我理解“this”是调用对象的引用。
我习惯在代码中看到像这样的“this”:
但是我看到了这些代码行:
示例1:
我习惯在代码中看到像这样的“this”:
var Person = function() {
this.name = "foo";
}
但是我看到了这些代码行:
示例1:
function helloWorld1() {
this({ body: "Hello world!" })();
}
示例2:
我还看到了这段代码:
function helloWorld2() {
this
({ body: "Hello, " })
({ body: "world!" })
();
}
- 这里的"this"是什么意思?
- 上面的例子中发生了什么?
this.name
而不是self.name
? - Daniel Vassallo