為什麼需要學函式? 其實就是希望一連串的程式都可以包裝成指令。如上圖的機器人,如果沒有下指令的話,他不知道該做什麼事。若透過函式的方式把一連串的程式碼變成一個指令,就可去執行。
DOM (Document Object Model,文件物件模型),是一個以樹狀結構來表示 HTML 文件的模型,而組合起來的樹狀圖,我們稱之為「DOM Tree」。我們把 HTML 每個節點的關係攤來看,就好像是一棵樹一樣。
為什麼要使用陣列來記錄資料呢 ? 試想,若在一家超市裡有賣很多品項的水果,如果只用變數記錄這些品項,資料就會顯得冗長,無法有條理地整理資料。
在學習這章節時,花了很多時間去參考別人的心酸血淚技術文,也看了許多令人崩潰的範例。隱含轉型並沒有在程式碼中明確指出要轉換,結果型別卻偷偷改變了,這常是踩坑的地方。我們來看看到底隱含轉型在背地裡做了什麼好事。
純值是使用複製的概念在傳值,物件是使用傳參考的特性在傳址。這樣的好處是我們在操作物件時,可以輕易地用更短的變數來操作 ; 壞處是操作物件時,容易因參考位置不同給搞混了,這章節主要在介紹物件傳參考的特性,將配合使用 Excell…
此次內容是 JavaScript 的流程判斷。用途會是在驗證資料是否有與原本設定的條件相同,例如:今天可以設計一個計算腰圍的程式,如果男生腰圍大於 90,就會回傳體重過重的流程判斷。
程式語言都具有資料結構,「型別」是固有的、內建的特徵,能唯一識別特定值的行為。例如:數字 123 和字串 ‘123’ 就是不一樣的,數字 123 可做數學運算處理,而字串 ‘123’ 可能就是做些顯示到畫面上的操作。
為什麼明明是「數字」最後卻自動轉換成「字串」型別呢?
為什麼明明是「基本型別」卻會有「屬性」以及「方法」可以呼叫?
因為「箭頭函式」運作邏輯和傳統 JS 觀念上會有不同,在撰寫上也容易有很多大雷點容易踩坑。我們來看看實作中使用「箭頭函式」會遇到什麼樣的問題,又該如何解決。