// 数组去重---2022-06-14 // 二维数组 var arrshuang = [1, -5, -4, [0, -4, 7], 7, 3, [2, 3, 4]] var result = [] function unique(arrIn) { for (var i = 0; i < arrIn.length; i++) { if (typeof arrIn[i] === 'number') { if (result.indexOf(arrIn[i]) === -1) { result.push(arrIn[i]) } } if (typeof arrIn[i] === 'object') { result = unique(arrIn[i]) console.log(result) } } return result } console.log('shuangchong', unique(arrshuang))