JavaScript Object Oriented Programming: Early and Late Binding
10 Feb 2016JavaScript 在呼叫的時候設定 this 的值,而這個 this 的值有可能不是我們預期的結果。下面有幾個範例。
JavaScript 在呼叫的時候設定 this 的值,而這個 this 的值有可能不是我們預期的結果。下面有幾個範例。
Factory Constructor Pattern 不使用 new 來宣告新物件,新物件用 function call 來建立。
在 pseudo-classical pattern 中,物件是由「建構子」(constructor)這個函式所建立,並把 method 放到建構子的 prototype 中。