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]