js简单数组去重
2021-04-30 22:29
标签:数组 bsp includes push ret unique rev for each demo1: function uniqArray(array){ return [...new Set(array)] demo2: function uniqArray(array){ var newArray = []; array.forEach(value=>{ return newArray; } demo3: function uniqArray(array){ return array.filter(function(item, index, arr){ } demo4: function unique(array){ return array.reduce((prev,cur) => prev.includes(cur) ? prev : [...prev,cur],[]); js简单数组去重 标签:数组 bsp includes push ret unique rev for each 原文地址:https://www.cnblogs.com/kmqz/p/13226013.html
}
if(newArray.indexOf(value)=== -1){
newArray.push(value)
}
})
return array.indexOf(item, 0) === index;
}
}
下一篇:javascript闭包