You just cannot use some tricks in JavaScript as you do in your php. It’s because JavaScript is meant to be more awesome.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | var arr = []; arr[0]=1; // arr has [1] arr[9]=4; console.log(arr) // [1, undefined × 8, 4] arr[-8]='something' arr[2.5]='somethine else' arr['hold'] = 'next one' //Here too, console.log won't show you all values. But don't worry. dir(arr) // It will show you the full list, but it's not use full |
There are not counted as the member of array.
Array in JavaScript array are really not as simple as in php.
You won’t get those members iterated in loop either.
So if you ever need to use those, Object is only the way out.
Everything is awesome.
Be First to Comment