次世代 Hugo

智能を研ぎ、創造を編む

Closure 與 Scope Chain

ECMAScript 除了 Promise Chain 外,還有所謂的 Scope Chain,當 Inner Function 存取 Variable 時,會依序以 Local Scope、Lexical Scope,最後才是 Global Scope 尋找,此稱為 Scope Chain。

ECMAScript 之 let

ECMAScript 2015 是 ECMAScript 歷史上最重要一次升級,也讓 ECMAScript 終於趕上主流程式語言高度,若要明顯的分辨 ES5 與 ES6,最明顯的方式的方式就是看有沒有使用 let

ECMAScript 之 this

this 在 OOP 相對單純,都是代表固定 Object,但在 ECMAScript 則是嚴肅課題,主要是 ECMAScript 是以 Function 為核心,OOP 是由 Function 實現,因此 this 觀念大異其趣。

ECMAScript 之 OOP 使用 this

ECMAScript 是一個包含多種 Paradigm 的程式語言,當使用 this 時,基本上就是以 OOP 風格開發,以 this 指向 Object。目前 ECMAScript 有 Object Literal、Constructor Function 與 Class 三種方式實現 OOP,將分別討論之。