为什么还会执行,num数组的值与header下标相同的也执行了
let num = [1,2] //存储不执行的下标
let header = ['en','xx','vv','ccc','ccx']
for(let i=0;i<header.length;i++) {
num.forEach((el) => {
if(i !== el) {
console.log(header[i])
}
})
}
为什么还会执行,num数组的值与header下标相同的也执行了
let num = [1,2] //存储不执行的下标
let header = ['en','xx','vv','ccc','ccx']
for(let i=0;i<header.length;i++) {
num.forEach((el) => {
if(i !== el) {
console.log(header[i])
}
})
}
13 回答12.7k 阅读
7 回答1.8k 阅读
3 回答1k 阅读✓ 已解决
3 回答1.2k 阅读✓ 已解决
2 回答1.1k 阅读✓ 已解决
2 回答1.8k 阅读
2 回答1.1k 阅读✓ 已解决
并没有执行
num.forEach()每次都和num内的所有值比较一遍 执行的是不同的
你的意思是这个吧