示例:我有一个包含重复值 1 和 2 的数组
[1,1,2,2,3,4,5]
我希望该数组的结果是不重复值的数组。
[3,4,5]
最佳答案
var arr = [1,1,2,2,3,4,5]
arr = arr.filter (function (value, index, array) {
return array.indexOf (value) == array.lastIndexOf(value);
});
console.log(arr);
关于javascript - 删除数组中所有重复的值,并保留 Javascript 中不重复的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40029252/