Associative arrays in JavaScript¶
Also called dictionaries.
Associative arrays are not supported by default, but they can by:
- creating empty arrays
- adding elements to the array with named indexes
This procedure will convert the arrays into objects.
Example:
var person = [];
person["name"] = "John";
person["age"] = 39;
However, this procedure is not safe and not recommended. It is recommended to use objects instead of associative arrays.