Why does this log output show the same answer in each iteration?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/11214430/wrong-value-in-console-log">Wrong value in console.log</a><br>
  <a href="http://stackoverflow.com/questions/12854644/what-does-in-javascript">What |= does in JavaScript?</a>  </p>
</blockquote>



<p>OK, I was <a href="http://www.html5rocks.com/en/tutorials/speed/v8/" rel="nofollow">reading an article</a> on optimising JS for Googles V8 engine, when i saw this code example...</p>

<p>I nearly skimmed over it, but then I saw this; |=; <strong>a[0] |= b;</strong></p>

<pre><code>a = new Array();
a[0] = 0;
for (var b = 0; b &lt; 10; b++) {
  console.log(a, b)
  a[0] |= b;  // Much better! 2x faster.
}
</code></pre>

<p>a[0] |= b;</p>

<p>So I ran it, in my console, with a console.log in the loop and resulted in 15;</p>

<pre><code>[15] 0
[15] 1
[15] 2
[15] 3
[15] 4
[15] 5
[15] 6
[15] 7
[15] 8
[15] 9
</code></pre>

<p>WHAT?!?! Where the hell does it get 15 from, on every iteration?!?!?!</p>

<p>I've been a web dev for 7 years, and this has stumped me and a fellow colleague.</p>

<p>Can somebody talk me through this code?</p>

<p>Cheers.</p>
