从JS数组中删除重复的值[duplicate]

☆樱花仙子☆ 提交于 2020-08-07 10:17:41

问题:

This question already has answers here : 这个问题已经在这里有了答案
Closed last year . 去年关闭。

I have a very simple JavaScript array that may or may not contain duplicates. 我有一个非常简单的JavaScript数组,其中可能包含重复项,也可能不包含重复项。

var names = ["Mike","Matt","Nancy","Adam","Jenny","Nancy","Carl"];

I need to remove the duplicates and put the unique values in a new array. 我需要删除重复项,并将唯一值放入新数组中。

I could point to all the codes that I've tried but I think it's useless because they don't work. 我可以指出我尝试过的所有代码,但是我认为这没用,因为它们不起作用。 I accept jQuery solutions too. 我也接受jQuery解决方案。

Similar question: 类似的问题:


解决方案:

参考一: https://stackoom.com/question/cj3F/从JS数组中删除重复的值-duplicate
参考二: https://oldbug.net/q/cj3F/Remove-duplicate-values-from-JS-array-duplicate
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!