Possible Duplicate:
What is the difference between object keys with quotes and without quotes?
I mostly know JavaScript from using it, but there’s something I don’t understand yet.
What’s the difference between these two object literals:
var obj1 = {
myProp: '123'
};
var obj2 = {
'myProp': '123'
};
Are they just ‘synonyms’, or is there a subtle difference?
Thanks!
In the object initializer syntax, keys can be numeric literals, identifiers, or strings.
After that the key is turned into a string regardless of what it was in the syntax, so in the case of
1e9the key will be a string"1000000000".