title: Bizarre console.log behaviour in Chrome Developer Tools
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4057440/is-chromes-javascript-console-lazy-about-evaluating-arrays">Is Chrome&#39;s JavaScript console lazy about evaluating arrays?</a>  </p>
  </blockquote>
  
  
  
  <p>Open up Chrome Developer Tools and type in:</p>
  
  <p><code>var a = [];console.log(a);a.push(1);console.log(a);</code></p>
  
  <p>You would expect this to output something like</p>
  
  <pre><code>[]
  [1]
  </code></pre>
  
  <p>But instead it outputs</p>
  
  <pre><code>[1]
  [1]
  </code></pre>
  
  <p>The behaviour is the same for</p>
  
  <p><code>var a = [];console.log(a);a[0] = 1;console.log(a);</code></p>
  
  <p>Can anyone explain this behaviour?</p>
  
  <p>Running Chrome on OS X. Same behaviour on 32bit Windows 7.</p>
  
  <p><strong>EDIT</strong>: The behaviour is the same regardless of whether the statements are on the same line or not. I have simply provided them on a single line to make it easy to test.</p>
  
  <p>Putting</p>
  
  <pre><code>var a = [];
  console.log(a);
  a.push(1);
  console.log(a);
  </code></pre>
  
  <p>in a file then running it yields the same behaviour.</p>
  
  <p><strong>EDIT x 2</strong>
  See: <a href="http://jsfiddle.net/9N4A6/" rel="nofollow noreferrer">http://jsfiddle.net/9N4A6/</a> if you don't feel like making a file to test.</p>