Unexpected behavior with Javascript array methods
<p>Take the following code</p>

<pre><code>var a = b = [];
a.push('value');
if (a === b) {
    console.log('a === b'); // this will execute
}

console.log(a, b); // ["value"] ["value"]
</code></pre>

<p>What gives? Why are both <code>a</code> and <code>b</code> modified? Is the <code>var</code> declaration making <code>b</code> a live copy of <code>a</code>? If so, then how come the same cannot apply for regular variable assignment such as:</p>

<pre><code>var a = b = '';
a = 'value';
if (a === b) {
    console.log('a === b'); // this will never run
}

console.log(a, b); // value
</code></pre>

<p>Of course, using the following declaration solves the problem in the initial example:</p>

<pre><code>var a = [], b = [];
</code></pre>

<p>But the behavior in the initial example struck me as odd, especially that it only applies to array operations.</p>

<p>If it helps, I'm using Google Chrome 10.0.648.82 beta</p>
