数组去重
var testarr = [11,2,6,31,31,31,31,11,2,5] // 数组去重 function deleteSome(arr) { var newarr = [] arr.map((item)=>{ if(newarr.indexOf(item) < 0) { newarr.push(item) } }) return newarr } var afterDelete = deleteSome(testarr) console.log(afterDelete) // [11, 2, 6, 31, 5]
作者:牧羊狼
出处:https://www.cnblogs.com/edwardwzw/
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利,谢谢您的配合。
Freedom is not let you do whatever you wanna but teach you not to do the things that you donnot wanna do.