最新文章
混合 Dev 和 Life 的所有最新內容
183 篇2026-06-2718 分鐘閱讀
從零開始逐步建立原型系統的完整心智圖:Object.prototype、函式的 prototype 屬性、new 建立的連結、原型鏈的查找,以及 constructor 與 dunderproto 的真實本質。
Deep JavaScript Foundations v3
#JavaScript #frontendMasters #deepJavaScriptFoundationsV3 #PrototypeChain #OOP #ClassSyntax #ThisKeyword 2026-06-279 分鐘閱讀
探討 JavaScript 原型系統與傳統類別理論的根本差異——類別導向語言透過複製建立實例,而 JavaScript 透過連結實作原型系統,兩種心智模型的落差正是 bug 的根源。
Deep JavaScript Foundations v3
#JavaScript #frontendMasters #deepJavaScriptFoundationsV3 #PrototypeChain #OOP #ClassSyntax 2026-06-2611 分鐘閱讀
說明為何「讓 class 方法自動硬綁定」是一個壞主意:展示用 getter 加 WeakMap 實作自動綁定的複雜 hack,以及這個做法如何從根本上違背 JavaScript this aware 函式的動態設計本質。
Deep JavaScript Foundations v3
#JavaScript #frontendMasters #deepJavaScriptFoundationsV3 #ThisKeyword #class 2026-06-2615 分鐘閱讀
介紹 ES6 class 語法的基本用法、extends 繼承與 super 相對多型。說明 class 方法傳遞為 callback 時同樣會遺失 this 綁定,以及用箭頭函式「修復」這個問題所帶來的自我矛盾代價。
Deep JavaScript Foundations v3
#JavaScript #frontendMasters #deepJavaScriptFoundationsV3 #ThisKeyword #class 2026-06-2512 分鐘閱讀
說明物件字面值的大括號不是範疇,因此物件內的箭頭函式會直接向上查找到全域範疇。整理箭頭函式唯一值得使用的場景(需要詞彙 this 時)、var self = this 的命名問題,以及箭頭函式不是第五條 this 規則的收尾論點。
Deep JavaScript Foundations v3
#JavaScript #frontendMasters #deepJavaScriptFoundationsV3 #ThisKeyword #ArrowFunction 2026-06-2510 分鐘閱讀
釐清箭頭函式的 this 行為:它不是「硬綁定到父層 this」,而是根本不定義 this,讓 this 像普通變數一樣沿詞彙範疇向上查找。說明為什麼這兩種理解方式在 new 關鍵字的角落案例上會產生根本差異。
Deep JavaScript Foundations v3
#JavaScript #frontendMasters #deepJavaScriptFoundationsV3 #ThisKeyword #ArrowFunction 2026-06-2413 分鐘閱讀
介紹 this 的第四種規則:預設綁定。說明非嚴格模式下退回全域物件、嚴格模式下為 undefined 並拋出 TypeError 的原因,並整合四種規則建立判斷 this 的完整框架。
Deep JavaScript Foundations v3
#JavaScript #frontendMasters #deepJavaScriptFoundationsV3 #ThisKeyword 2026-06-248 分鐘閱讀
介紹 new 關鍵字作為第三種 this 綁定方式:說明用 new 呼叫函式時依序發生的四件事,以及為什麼 new 更像是劫持了函式、由關鍵字本身完成所有工作。
Deep JavaScript Foundations v3
#JavaScript #frontendMasters #deepJavaScriptFoundationsV3 #ThisKeyword 2026-06-2315 分鐘閱讀
介紹 this 的前兩種呼叫規則:隱式綁定(點號左側的物件)與明確綁定(.call / .apply)。說明傳遞函式導致 this 遺失的問題、.bind() 硬綁定的解法,以及 Kyle Simpson 對彈性與可預測性的設計取捨框架。
Deep JavaScript Foundations v3
#JavaScript #frontendMasters #deepJavaScriptFoundationsV3 #ThisKeyword 2026-06-2311 分鐘閱讀
介紹 this 關鍵字的核心概念:this 的值由函式的呼叫方式決定,與定義位置無關。說明 this 與動態範疇的概念對比,以及後續四種呼叫方式的學習路徑。
Deep JavaScript Foundations v3
#JavaScript #frontendMasters #deepJavaScriptFoundationsV3 #ThisKeyword MIT Licensed | Copyright © 2025-present Wen-Hsiu's Blog

