This has got to be a thing. If I have something like this in Javascript
这必须是一件事。如果我在Javascript中有这样的东西
var c = 0;
var arr = [
[a,b,c,d],
[e,f,g],
[h,i,j,k,l]
];
for(var i = 0; i < arr.length; i++){
for(var j = 0; j < arr[i].length; j++){
}
}
How do I get a single 0-based index based off of i and j? To be clear, after every iteration of the inner j loop c should increment to the next number in 0 - 11.
如何根据i和j获得单个基于0的索引?需要明确的是,在内部j循环的每次迭代之后,c应该递增到0-11中的下一个数字。
1 个解决方案
#1
0
I think this is what you want
我想这就是你想要的
var arr = [
['a','b','c','d'],
['e','f','g'],
['h','i','j','k','l']
];
var output = [];
arr.forEach(function(item){
output.concat(item);
});
Output:
['a','b','c','d','e','f','g', 'h','i','j','k','l']
#1
0
I think this is what you want
我想这就是你想要的
var arr = [
['a','b','c','d'],
['e','f','g'],
['h','i','j','k','l']
];
var output = [];
arr.forEach(function(item){
output.concat(item);
});
Output:
['a','b','c','d','e','f','g', 'h','i','j','k','l']