Javascript

How to get/check javascript execution time

最近開始睇下D algorithm 既 tutorial 想了解下學左 / 用左會 efficient 幾多呢 這個當然要用時間來 value 最簡單既方法就係計 execution time 在javascript 上如何計execution time 呢? ** 解決方法 ** 我們可以使用 console.time(); …

Create-React-App test without watch mode

最近嘗試在 React App 上加入 Coverage Report… 可能是因為是用了create-react-app 所以在使用 yarn test 的時候便自己加了 watch mode.. create-react-app test 當有 code change 時便會再 test 一次.. 在 console 上不停顯示 code …

ReactJs set base path -

係 GitHub 用 GitHub Page Host 果個 ReactJs Project 由於個 Page 係 Subfolder 同 存放 e.g. https://sharechiwai.github.io/code-playground 而不是 https://sharechiwai.github.io 所以當我 reploy ReactApp 到 …

JS format JSON

如何用 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" } …

How to get distinct values from an array of objects in JavaScript

今日有個 task 其中一個地方要在 Array of Json object 中 Distinct 一個 property const data = [ { id: 1, category: 'fruit', name: 'Apple', }, { id: 2, category: 'fruit', name: 'Banana', }, { id: 3, …

ESLint couldnt find the plugin (when install dependencies using yarn)

今日嘗試用 command line (CLI) 執行 ESLint 時出現了以下的錯誤信息 # eslint command eslint ./src Error: Cannot find module 'eslint-config-airbnb'