Why does this code work?
<p>I thought if statements weren't supposed to contain assignment operators but rather the comparison operators (==, ===) but this works perfectly. Why?</p>

<pre><code>var foo = true,
    bar = true;
if (foo = true) {
    console.log('foo is true');
}
</code></pre>

<p>I was taught that this wouldn't work but I just found out that it does.</p>
