Using an integer as a key in an associative array in JavaScript

Solution 1:

Use an object, as people are saying. However, note that you can not have integer keys. JavaScript will convert the integer to a string. The following outputs 20, not undefined:

var test = {}
test[2300] = 20;
console.log(test["2300"]);

Solution 2:

You can just use an object:

var test = {}
test[2300] = 'Some string';