Day 15:this 關鍵字 (1)
this 的簡單範例
var ironMan = {
firstName: "Tony",
lastName : "Stark",
getFullName : function() {
return this.firstName + " " + this.lastName;
}
};
console.log(ironMan.getFullName()); // "Tony Stark"JavaScript 的 this 很複雜?
全域執行環境下 (Global Context)
函數執行環境下 (Function Context)
1. 物件函式 (As an Object Method)
1.1. 函數被定義在物件之內
1.2. 借用函數 (函數被定義在物件之外)
1.3. 物件的屬性物件的函式
References
Last updated
Was this helpful?

