So, you want an array of arrays, eh? Why are you using the old-style technique of "coarray[loop1] = new Array()" instead of using the newer literal array "coarray = []" syntax? You could even combine the the literal array syntax with literal object syntax to make your program easier to read:
var coarray = [
{color: "Black"},
{color: "Brown"},
{color: "Red"},
{color: "Orange"},
{color: "Yellow"},
{color: "Green"},
{color: "Blue"},
{color: "Violet"},
{color: "Grey"},
{color: "White"},
{color: "Gold"},
{color: "Silver"},
{color: "None"}
];
Then you could access the array like this:
var myColor = coarray[0].color;
... or even:
var myColor = coarray[0]["color"];
Of course, if you're really attached to your array of arrays approach, you can do this:
var coarray = [
["Black"],
["Brown"],
["Red"],
["Orange"],
["Yellow"],
["Green"],
["Blue"],
["Violet"],
["Grey"],
["White"],
["Gold"],
["Silver"],
["None"]
];
... and still access it like this:
var myColor = coarray[0][0];
It's your choice. Good luck.
2007-09-21 05:37:15
·
answer #1
·
answered by §©®Î¶†Δ® 4
·
0⤊
0⤋
Well you have come up with a solution and an answer. But what are you trying to do?
You have a two dimension array that only has element [n][0] set to a value. Why what is the point?
If you do not understand how to access an array then why are you using an array?
Oh, I see you don't want hassle! That is not the only reason for using an array.
2007-09-20 19:45:11
·
answer #2
·
answered by AnalProgrammer 7
·
0⤊
0⤋