参考let arr = [1,22,3,1];let reps = arr.some((ele,ind)=>{ if(arr.indexOf(ele) !== ind){ console.warn(`元素:${ele},下标:${ind}`); }}); 参考 Find duplicates in an array using javaScript