标签:bsp class console var 去重 nbsp dedup 实现 turn
var set = new Set();
var arr = [1, 2, 3, 3, 2, 1];
arr.map(val => set.add(val));
// arr.map(function(val) {
// set.add(val);
// })
arr = [];
for(i of set) {
arr.push(i);
}
console.log(arr) // [1, 2, 3]
function dedupe(array) { return Array.from(new Set(array)); } dedupe([1, 1, 2, 3]) // [1, 2, 3]
标签:bsp class console var 去重 nbsp dedup 实现 turn
原文地址:http://www.cnblogs.com/txxt/p/6107041.html