I'm trying to create an associative array...create an empty array, then add a (indexName -> value) pair:
var arrayName = new Array;
arrayName["indexName"] = value;
// i know i can also do the last line like this:
arrayName.indexName = value;
When i assign the value to the indexName i want indexName to be dynamic...to be the value of a variable...so i tried this:
arrayName[eval("nume")] = value;
where:
var var1 = "index";
var var2 = "Name";
var nume = '"' + var1 + var2 + '"'; // single quote double quote single quote + var1 + ...
but: alert(arrayName["indexName"]);
doesn't return "value"...it says "undefined"
Is there something i'm missing? (i'm not familiar with eval()
); if the way i'm trying is a dead end, is there another way to make the index name of the associative array value...dynamic...i hope you know what i mean :)
Gracias