0

If I have this code :

o["a"]=1;
o["b"]=1;
o["c"]=1;
o["d"]=1;


for (var k in o)
{
  alert(k)
}
  • Would it always(cross browser) be alerted in the same order as the attribute were added ?

  • And what about this ? (same question)

    var o={a:1,b:1,c:1,d:1} ?

0

1 Answer 1

2

No. The order is not specified. From the spec:

The mechanics and order of enumerating the properties ... is not specified.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.