let arr1 = [1, 2, 3, 4, 2];
for (let i = 0; i < arr1.length; i++) {
let arr2 = [...arr1];
arr2.splice(i, 1);
test(arr1[i], arr2);
}
function test(ele, arr) {
for (let i = 0; i < arr.length; i++) {
if (ele == arr[i]) {
console.log(123, arr[i])
} else {
console.log(234, arr[i])
}
}
}
js 取数组一个元素 与剩余的每个元素作比较
最新推荐文章于 2024-05-09 16:02:08 发布