javascript splice() indexing problem
- by markzzz
hello! i have to add some value into an array.
code for example :
temp[0]=new Array("0","0");
temp[1]=new Array("0","0");
temp[2]=new Array("0","0");
temp[3]=new Array("0","0");
temp[4]=new Array("0","0");
vt=new Array("1","0");
temp.splice(3, 0, vt);
temp.splice(4, 0, vt);
temp[3][1]="R";
i aspect this output :
1 - 0,0
2 - 0,0
3 - 0,0
4 - 1,R
5 - 1,0
6 - 0,0
7 - 0,0
but the output is :
1 - 0,0
2 - 0,0
3 - 0,0
4 - 1,R
5 - 1,R
6 - 0,0
7 - 0,0
any idea? i think it's a indexing problem with splice() function!
cheers