JS Array 刪除重複元素的三種方式
- Set(ES6): 最簡單,效率最高。
- Array.filter:常用的方式,目前個人習慣的寫法。除了可以用來找不重複元素,也可以反向來找到重複元素。
- Array.reduce:效率最差,看起來較不直觀。
紀錄一下今天晚上看完的文章,順便練習一下JS,剛好最近也在看一些關於JS’s Set的相關語法,趁機寫下本文,以供後續查找。
參考:
JS Array 刪除重複元素的三種方式
紀錄一下今天晚上看完的文章,順便練習一下JS,剛好最近也在看一些關於JS’s Set的相關語法,趁機寫下本文,以供後續查找。
參考:
Distraction-free reading. No ads.
Organize your knowledge with lists and highlights.
Tell your story. Find your audience.
Read member-only stories
Support writers you read most
Earn money for your writing
Listen to audio narrations
Read offline with the Medium app
Keeping the mind to Learn Anything. Github: https://github.com/gotraveltoworld