最近開始睇下D algorithm 既 tutorial 想了解下學左 / 用左會 efficient 幾多呢 這個當然要用時間來 value 最簡單既方法就係計 execution time 在javascript 上如何計execution time 呢? ** 解決方法 ** 我們可以使用 console.time(); console.timeEnd(); 來記錄 javascript 的 execution time e.g.
2021-07-03
最近嘗試在 React App 上加入 Coverage Report… 可能是因為是用了create-react-app 所以在使用 yarn test 的時候便自己加了 watch mode.. create-react-app test 當有 code change 時便會再 test 一次.. 在 console 上不停顯示 code coverage 便很繁忙了 如果可以在 run code coverage report 時停了 watch 便好
2020-08-12
係 GitHub 用 GitHub Page Host 果個 ReactJs Project 由於個 Page 係 Subfolder 同 存放 e.g. https://sharechiwai.github.io/code-playground 而不是 https://sharechiwai.github.io 所以當我 reploy ReactApp 到 GitHub Page 上時 當 click 去任何一條 Link 時..他沒有 suffix code-playground e.g.(contact) 便 navigate 去了 https://sharechiwai.github.io/contact 而不是很聰明地 去 https://sharechiwai.github.io/code-playground/contact
2020-08-10
如何用 Javascript format JSON 解決方法: 我們可以使用JSON.stringify 來 format e.g. var c = {a : "test", b:{ data: "asdada"}} JSON.stringify(c, null, 4) "{ "a": "test", "b": { "data": "asdada" } }" Hope you find it useful
2019-11-23
今日有個 task 其中一個地方要在 Array of Json object 中 Distinct 一個 property const data = [ { id: 1, category: 'fruit', name: 'Apple', }, { id: 2, category: 'fruit', name: 'Banana', }, { id: 3, category: 'herb', name: 'Basil', }, { id: 4, category: 'herb', name: 'Rosemary', }, { id: 5, category: 'fruit', name: 'Dragon Fruit', }, ]; 解決方法: (ES5)
2019-06-25
今日嘗試用 command line (CLI) 執行 ESLint 時出現了以下的錯誤信息 # eslint command eslint ./src Error: Cannot find module 'eslint-config-airbnb'
2019-04-07