Can I depend on the following code alerting b before a?
var x = {}
x['b'] = 1
x['a'] = 0
for(var i in x) {
alert(i)
}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
For the V8 JavaScript engine used in Google Chrome, a similar discussion took place:
http://code.google.com/p/v8/issues/detail?id=164
It’s better to not rely on undocumented features. And it you’re using numbers as keys, it certainly goes wrong.
For example this breaks in some browsers:
BTW it’s
alert(x[i]).