javascript splice() indexing problem
Posted
by markzzz
on Stack Overflow
See other posts from Stack Overflow
or by markzzz
Published on 2010-06-12T13:37:57Z
Indexed on
2010/06/12
13:43 UTC
Read the original article
Hit count: 212
JavaScript
|splice
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
© Stack Overflow or respective owner