let arr = [1, 2, 3, 4, 3, 2, 3, 4, 6, 7, 6] let unique = (arr) => { console.log(arr) return arr.filter((item, index) => { // console.log(item, index) indexOf 返回第一个索引 return arr.indexOf(item) === index }) } console.log(unique(arr))标签:index,arr,console,log,indexOf,filter,数组 From: https://www.cnblogs.com/zhulongxu/p/16617362.html