0
help me out with arrays please
I'm telling the code to remove the following array (1,2) which should be Mike and pauljerq and I expected to have jones remaining, surprisingly I'm getting "Mike" on the output, can someone please tell me why? var users = ["Jones" , "mike", "pauljerq"]; var slice= users.slice(1,2); document.write(slice)
3 Respuestas
+ 6
slice() selects the elements whose index is passed to it. And when you write slice(1,2) always remember that index 1 is only accessed and 2 is not included. So to print Jones you should write slice(0,1). I guess I am right.
So for eg if you say slice(5,10) then you can access index 5,6,7,8,9 but not 10.
+ 2
Glory222 you're welcome
0
Thanks