Oliver LiaoJavaScript中的forEach方法與陣列元素的修改JavaScript中的陣列操作是開發中常用的技巧之一,而其中的forEach方法是一個常用的陣列遍歷方法。Jun 1, 2023Jun 1, 2023
Oliver LiaoReact Hook: useContext 用法useContext 是 React Hooks 中的一個 Hook,它用於在 React 應用程式中共享狀態。通常是用來避免 props drilling (props 鉆孔) 的問題。當在應用程式中有多個元件需要訪問同一個狀態時,這時使用 useContext…Apr 29, 2023Apr 29, 2023
Oliver LiaoReact Hook: useCallback vs. useMemo在 React 中,當使用狀態和屬性等資料時,有時會面臨一些效能問題,例如資料過於龐大、重新渲染次數過多等。在這種情況下,可以透過 useCallback 和 useMemo 這兩個 hook 來優化 React 的效能。Apr 28, 2023Apr 28, 2023
Oliver LiaoJavaScript : Promise hell在 JavaScript 中,當需要處理多個非同步操作時,我們通常會使用 Promise 鏈式調用(Promise chaining)的方式,將多個非同步操作連接起來。然而,當 Promise 鏈式調用越來越長時,程式碼會變得難以維護和理解,這種現象稱為 Promise…Apr 26, 2023Apr 26, 2023
Oliver LiaoJavaScript : for…of/for…infor...of 和 for...in 都是 JavaScript 中用於迭代集合(例如陣列或物件)的迴圈結構。Apr 26, 2023Apr 26, 2023
Oliver LiaoJavaScript : Array.prototype.map()/.forEach在 JavaScript 中,map() 是一個內建的陣列方法,用於將一個函數應用到陣列中的每個元素,然後返回一個新的陣列,其中包含應用函數後的結果。Apr 26, 2023Apr 26, 2023
Oliver LiaoJavaScript : Array.prototype.reverse()/.sort()在 JavaScript 中,reverse() 和 sort()是陣列的內建方法,用於對陣列元素進行反轉和排序操作。Apr 26, 2023Apr 26, 2023