JavaScript 是一種直譯執行的腳本語言,具備動態型別、弱型別、基於原型繼承等特性,內建支援 JSON、正則表達式、閉包、非同步程式設計等現代語言特徵。廣泛應用於瀏覽器端互動、Node.js 伺服器端、桌面應用、行動應用開發。本文系統整理主流 JavaScript 基礎課程的核心知識點,供初學者建立完整知識地圖。
| 主題 | 核心知識點 |
|---|---|
| 變數與資料型別 | var/let/const 作用域差異、基本型別 (String, Number, Boolean, Null, Undefined, Symbol, BigInt)、參考型別 (Object, Array, Function)、型別轉換與 === vs == |
| 運算子與流程控制 | 算術/比較/邏輯/位元/三元/解構賦值、if/else、switch、for/while/do-while、for...in/for...of、標籤語句 |
| 函數 | 函數宣告 vs 運算式、箭頭函數 (=>)、參數預設值、剩餘參數 (...args)、展開運算子、閉包、遞迴、高階函數、this 綁定規則 |
| 物件與原型 | 物件字面量、建構函數、prototype 鏈、Object.create、class 語法糖、繼承、super、混入、屬性描述符 |
| 類別 | 常用方法/屬性 |
|---|---|
| Array | map/filter/reduce/find/findIndex/some/every/flat/flatMap/sort/splice/slice/concat/from/of |
| String | trim/split/replace/replaceAll/match/matchAll/startsWith/endsWith/includes/padStart/padEnd/template literal |
| Object | keys/values/entries/assign/freeze/seal/defineProperty/getOwnPropertyDescriptors/create |
| Map/Set | set/get/has/delete/clear/size/forEach/keys/values/entries、WeakMap/WeakSet |
| Date | now/parse/ISO 字串/時間戳/時區/格式化 (建議使用 date-fns、dayjs) |
| Math | random/floor/ceil/round/max/min/abs/pow/sqrt/PI/E |
| JSON | parse/stringify/replacer/reviver、循環引用處理 |
| RegExp | 字面量/建構函數、旗標 (g,i,m,s,u,y)、分組/捕獲/前瞻/斷言、exec/test/matchAll |
| 階段 | 技術 | 關鍵點 |
|---|---|---|
| 回調地獄 | Callback | 錯誤優先慣例、setTimeout/setInterval |
| Promise | ES2015 | then/catch/finally、Promise.all/race/allSettled/any、鏈式調用、錯誤傳播 |
| Async/Await | ES2017 | 語法糖、try/catch 同步化錯誤處理、並行 Promise.all、頂層 await |
| 迭代器/生成器 | ES2015 | Symbol.iterator、function*、yield/yield*、非同步生成器 for await...of |
querySelector/all、getElementById)、遍歷、建立/插入/移除/複製節點、DocumentFragment。addEventListener/removeEventListener、event.preventDefault/stopPropagation、事件代理、自訂事件。window/navigator/screen/location/history、localStorage/sessionStorage/IndexedDB、Cookie。fetch API、Request/Response/Headers、CORS、Service Worker、WebSocket、Server-Sent Events。| 主題 | 重點 |
|---|---|
| ES Modules | import/export、動態 import()、import.meta、Tree Shaking |
| CommonJS | require/module.exports、Node.js 相容、循環依賴 |
| 打包工具 | Webpack/Vite/Rollup/esbuild、Loader/Plugin、Code Splitting、HMR |
| 轉譯 | Babel/SWC、Preset/Plugin、Target 瀏覽器、Polyfill |
| 代碼品質 | ESLint/Prettier/TypeScript、Git Hooks (Husky)、CI/CD |