Answer the question
In order to leave comments, you need to log in
Objects in JavaScript. Why is 1 displayed and not 0?
var obj = {'1': 0, 1: 1, 0: 2};
alert(obj['1']);
Why is the value of property 1 displayed and not property '1' ?
We are referring to the property '1', not 1.
Answer the question
In order to leave comments, you need to log in
Because the key is always a string. Any other types are cast to string
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question