How correct is it to use || as "ifnull" in JavaScript?
<p>I've seen code like this on the web:</p>

<pre><code>function MyEventHandler(e)
{
    var ev = e || event;
    var target = ev.srcElement || ev.target
}
</code></pre>

<p>In essence, the <code>||</code> operator is used as a shorthand for <code>a?a:b</code>. As far as I can tell - it works on all browsers. But bringing up specs for, say, JScript, <a href="http://msdn.microsoft.com/en-us/library/xxxekd04(v=VS.85).aspx" rel="nofollow">I see</a>:</p>

<blockquote>
  <p>Performs a logical disjunction on two expressions.</p>
</blockquote>

<p>and</p>

<blockquote>
  <p>JScript uses the following rules for converting non-Boolean values to Boolean values: </p>
  
  <ul>
  <li>All objects are considered true. </li>
  </ul>
</blockquote>

<p>So... according to this the result should be a boolean true/false. I'm just wondering - am I walking the knife-edge of undocumented behavior, or is there some fine implication here that I haven't picked up?</p>
