let arr =[1,1,2,3]; (按执行时间排序) 1. newArr = new Set(arr); 2.newArr = Array.from(new Set(arr)); 3.var newArr = []; for (var i = 0; i < arr.length; i++) { if (!map.has(arr[i])) { //查找是否含有key map.set(arr[i], true) //添加key和value console.log(map) newArr.push(arr[i]); } } 4. var arr2 = [] for (j = 0; j< arr.length; j++) { if(!newArr.includes(arr[j])){ newArr.push(arr[j]) } } 5.双层循环去重; 6.利用indexOf for (j = 0; j< arr.length; j++) { if(newArr.indexOf(arr[j])==-1){ newArr.push(arr[j]) } } 7. newArr=arr.filter((item,index)=>{ return arr.indexOf(item)===index //数组包含item的值则返回对应的下标 }) 空间复杂度最低: var removeDuplicates = function(nums) { let i = 0; while(i<nums.length-1){ if(nums[i] === nums[i+1]){ nums.splice(i,1); }else{ i++ } } };