我需要cells
按照我的评论中的描述创建一个数组。我想知道这个脚本有什么问题,以及实现这个结果的更高效的方法。
看看 js fiddle http://jsfiddle.net/XvTrf/5/
var data = ['D-0','D-1','D-2','D-3','D-4','D-5','D-6','D-7','D-8','D-9'];
var cells=[];
var d = 0, lenD = data.length;
while(d< lenD){
if(d === 1 || d === 5 || d ===6){
cells.push('test');
}else {
cells.push(data[d]);
}
d++;
}
console.log(cells);
/* result wanted
D-0
test
D-1
D-2
D-3
test
test
D-4
D-5
D-6
D-7
D-8
D-9
*/