Suppose I have a Javascript object which is initialized
var letters = {q:0, t:0, o:0, b:0, y:0, n:0, u:0, m:0, p:0,
w:0, a:0, d:0, k:0, v:0, c:0, z:0, l:0, j:0,
i:0, e:0, g:0, s:0, x:0, r:0, h:0, f:0};
and then I want to iterate over the keys of this objects
for(var letter in letters) {
// code goes here
}
In both Firefox 3 and Internet Explorer 8 the objects are iterated over in the order in which they are listed in the object declaration (q, t, o, b, y, etc).
Can I rely on this? Assume that I don't modify my object in any way before the iteration. Is it part of the ECMAScript standard? Does anyone know which browsers iterate in the declared order?