This is regarding using OO concepts in jQuery.
I want to create an array of structures in jQuery so that I can save a char and an integer in same the element of an array.
I want to store 'Y' and 2 in each element of array, so that I can change the value of the integer based on whether the value of the char is 'Y'.
I have the following code
var arrOfArr = new Array(3);
for (var x = 0; x < arrOfArr.length; x++) {
arrOfArr[x] = [new struct('Y', 0),new struct('Y', 0),new struct('Y', 0)];
}
function struct($user, $turnCount) {
var user = $user;
var turnCount = $turnCount;
}
Now when I call alert(arrOfArr[0][0].turnCount), it is giving undefined. But if I define arrOfArr[0][0].turnCount = 0 and again call the same alert it gives me 0.
Can you please help me understand how can I initialize an array of structures at the time of initialization?