Here is the example of what I am doing:
var size = new Array("S", "M", "L", "XL", "XXL");
var color =
I would create an object like this:
var options = {
size: ["S", "M", "L", "XL", "XXL"],
color: ["Red", "Blue", "Green", "White", "Black"]
};
alert(Object.keys(options));
To access the keys individualy:
for (var key in options) {
alert(key);
}
P.S.: when you create a new array object do not use new Array
use []
instead.
Array is just like any other object. You can give it a name if you want.
var size = new Array("S", "M", "L", "XL", "XXL");
var color = new Array("Red", "Blue", "Green", "White", "Black");
var options = new Array( size, color);
color.name = "color";
size.name = "size";
options[0].name == "size"
>true