My javascript hash on my web page looks like:
{"7":{"prop1":234, ....}"101":{"prop1":121,....}
I’m trying to reference it like this:
var a = 7;
my_hash[a].prop1
But it doesn’t seem to find the hash object at the key ‘a’, since a is an integer and my keys are strings.
How can convert it to a string?
I tried:
my_hash[" + a + "].prop1
But that didn’t work either.
Just create a string:
If you have a number already, and want to make it a string, coerce it to a string this way:
So, these all will work:
Edit: Some examples converting it to a string inline: