var num = [1, 2, 6, 4, 5, 8, 3, 9, 6, 8] var num1 = [] // 排序 for (let i = 0; i < num.length; i++) { for (let j = 0; j < num.length - i; j++) { if (num[j] > num[j + 1]) { let temp = num[j]; num[j] = num[j + 1]; num[j + 1] = temp; } document.write('我是第一行' + num[j]); } // 去重 if (num1.indexOf(num[i]) === -1) { num1.push(num[i]) } }