Is There a way to do an hash map in javascript that holds 1 key and 2 values?
For an hash map with key and value in javascript i can do something like this:
var userList = {
11234321:"koko",
22342342:"jojo",
32342423:"fofo",
42342342:"momo"
}
So for each ID number i have user name.
Now, i want to add another value, like: user age.
There is a way to do that? any other solution to the problem?
Essentially what you’re asking for is a multidimensional associative array. The JavaScript implementation of that is nested objects, along these lines:
Note that there is no limit to how deep these nests go.
To access a particular username, for example, you would access
userList[id]['username'](oruserList[id].username), just like an associative array in other languages.