Javascript examples for Array Operation:Array of Object
Creating a 2d array of objects in javascript
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=( function() {/*from w ww . j av a 2s. c om*/ var Coords = function(x, y) { return { "x" : x, "y" : y }; }; var myArray = []; for (var i = 0, l = 10; i < l; i++) { myArray[i] = []; for (var j = 0, l2 = 10; j < l2; j++) { myArray[i][j] = Coords(i, j); } } console.log(myArray); }); </script> </head> <body> </body> </html>