set用于数组去重

176 阅读1分钟
var arr=[2,2,3,1,4,5,4];

var s=new Set(arr);//将数组转化为set

var arr2=Array.from(s);//将set转化为数组

console.log(arr2);