JavaScript && opertor in return statement
<p>I have a piece of JavaScript code as follows:</p>

<pre><code>function main(condition){
    if(condition){
        doSomething();
        return obj;
    }
}
</code></pre>

<p>now I want to refactor this code to get rid of the "if" statement. Here is what I want to do</p>

<pre><code>function main(condition){
    var doSomethingAndReturnObj = function(){
        doSomething();
        return obj;
    }
    return condition &amp;&amp; doSomethingAndReturnObj();
}
</code></pre>

<p>here is where I need help. The caller of main function expects a return value of "undefined" or an obj. In my refactored code, would my </p>

<p><strong>return condition &amp;&amp; doSomethingAndReturnObj();</strong></p>

<p>convert the return value to a true and false type? </p>

<p>Thanks for your replies.</p>
