Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Interesting question. The answer lies in the <a href="http://es5.github.com/#x12.6.4" rel="nofollow">specification</a> (emphasis mine):</p> <blockquote> <p>The mechanics and order of enumerating the properties (step 6.a in the first algorithm, step 7.a in the second) <strong>is not specified</strong>. Properties of the object being enumerated may be deleted during enumeration. <strong>If a property that has not yet been visited during enumeration is deleted, then it will not be visited.</strong> If new properties are added to the object being enumerated during enumeration, the <strong>newly added properties are not guaranteed to be visited</strong> in the active enumeration. A property name must not be visited more than once in any enumeration.</p> </blockquote> <p>So it is explicitly specified that a deleted property must not be traversed anymore. However, the behaviour for adding a new property is implementation dependent, most likely because it is not defined how properties should be stored internally.</p> <p>For example in Chrome, it seems that numeric properties are stored before alphabetical ones:</p> <pre><code>&gt; Object.keys({a:0, 0:1}); ["0", "a"] </code></pre> <p>However, even if you add alphabetical keys:</p> <pre><code>var obj = {a:0,b:0}; for (var k in obj) { obj['c'] = 0; console.log(k); } </code></pre> <p><code>c</code> does not seem to be traversed, the output is <code>a b</code>.</p> <p>Firefox shows the same behaviour, although keys are stored in insertion order:</p> <pre><code>&gt; Object.keys({a:0, 0:1}); ["a", "0"] </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload