How to get the cell value in 2D array in Javascript
I have a table of numbers, which will 31 cols * 9 rows, I want to get the cell value from getting the spot function! so I want [1][2].the important value for me is Y only? how to pass theGrid to the spot function? also, any suggestions for performance will be fantastic as you can see the it is huge array
var cols = 31;
var rows = 9;
var theGrid = new Array(cols);
var i;
var j;
//get the spot
function getTheSpot(j, i) {
// when the col met the row it create a spot
//that what i need to get
this.y = i;
this.x = j;
return i;
return j;
}
//create a grid for the numbers
function createGrid() {
// BELOW CREATES THE 2D ARRAY
for (var i = 0; i < cols; i++) {
theGrid[i] = new Array(rows);
}
for (var i = 0; i < cols; i++) {
for (var j = 0; j < rows; j++) {
theGrid[j][i] = new getTheSpot(j, i);
}
}
}
var s = getTheSpot(9, 2);
console.log (s);