 <p>Javascript evaluates logic by truethness/falseness. Values such as (<code>false</code>, "", null, <code>undefined</code>, <code>0</code>, -0) are evaluated as logic false.</p> <p>Combine this with the lazy evaluation, 'OR' operations are now evaluated from <code>left to right</code> and <strong>stops</strong> once <code>true</code> is found. Since, in your example, the truthness is not literally a boolean, the value is returned.</p> <p>In this case:</p> <pre><code>x = 0; y = 5; alert(y || x)/*returns 5*/; alert(x || y)/*also returns 5*/; </code></pre> <p>this can also be other objects.</p> <pre><code>functionThatReturnsTrue() || functionThatDoesSomething(); </code></pre>