[OFF TOPIC]
quote:
Originally posted by tryxter
But if there's a way to do (or simply simulate) it, it should be explained, don't you think?
Which is clearly explained in the
JScript documentation:
quote:
Although JScript does not directly support multi-dimensional arrays, you can store any sort of data inside array elements — including other arrays. So you can get the behavior of multi-dimensional arrays by storing arrays within the elements of another array. For example, the following code builds a multiplication table for the numbers up to 5:code:
// Change this number for a bigger table
var iMaxNum = 5;
// Loop counters
var i, j;
// New array. Make it iMaxNum + 1 because arrays start
// counting at zero, not 1.
var MultiplicationTable = new Array(iMaxNum + 1);
// Loop for each major number (each row in the table)
for (i = 1; i <= iMaxNum; i++)
{
// Create the columns in the table
MultiplicationTable[i] = new Array(iMaxNum + 1);
// Fill the row with the results of the multiplication
for (j = 1; j <= iMaxNum; j++)
{
MultiplicationTable[i][j] = i * j;
}
}
window.alert(MultiplicationTable[3][4]); // Displays 12
window.alert(MultiplicationTable[5][2]); // Displays 10
window.alert(MultiplicationTable[1][4]); // Displays 4
Also, when one puts 1 plus 1 (elements of arrays can contain anything, including objects, and arrays are objects) you come automatically to how to make/simulate multidimensional arrays. I'm not sure if every basic thing you can do with objects, etc needs to be explained in 'tips'. It's basic programming...
[/OFF TOPIC]