Thursday, March 13, 2008

2D arrays in Javascript

Folks, here is an example of creating a 2D array in javascript:

var polygon = Array(10);
for (i=0; i <limit; i++)
polygon[i]=new Array(10);

Here, 'polygon' is a 1D array. Each array element of this 1D array is initialized to be arrays which

subsequently makes 'polygon' as a 2D array.


Keep posting... :)

No comments: