我想在里面循环一个数组并使用 JavaScript 数组
outerArray = ["1","2","3","4","5","6","7","8","9","10"];
innerArray = ["val-1","val-2","val-3"];
以便控制台注销:
1,val-1
2,val-2
3,val-3
4,val-1
5,val-2
6,val-3
7,val-1
8,val-2
9,val-3
10,val-1
使用:
for (var i = 0; i < outerArray.length; i++) {
console.log(i);
}
显然日志:1,2,3,4,5,......
但是我不能使用:
for (var i = 0; i < outerArray.length; i++) {
console.log(i+','+innerArray[i]);
}
因为这会在“val-3”之后给出未定义,因为它与外部数组的长度不同。