How to get unique values in an array

后端 未结 20 2243
情歌与酒
情歌与酒 2020-11-22 14:02

How can I get a list of unique values in an array? Do I always have to use a second array or is there something similar to java\'s hashmap in JavaScript?

I am going

20条回答
  •  野性不改
    2020-11-22 14:38

    Not native in Javascript, but plenty of libraries have this method.

    Underscore.js's _.uniq(array) (link) works quite well (source).

提交回复
热议问题