javascript - Meaning of declaration in JS - [[0]] -
does know meaning of declaration in js: var m = [[0]]; mean declarated type, , why 0 in brackets?
[0] array first index equal 0
[[0]] array first index equal array (whos first index 0)
it easier imagine if had more elements , space bit better:
var m = [[0,1,2],[2,4,5],[1,3]]
so
m[0] = [0,1,2]; m[1] = [2,4,5]; m[2] = [1,3];
this can expanded many dimensions need leading collections of collections of collections.
you can access each index , use array referencing instance:
m[0].push(4); m[2].join(',');
etc.
(as mentioned above) can access shorthand like:
m[0][0] m[x][y] m[n-1][m[0][1]]
making complicated or simple need.
Comments
Post a Comment