JavaScript && opertor in return statement -
JavaScript && opertor in return statement -
i have piece of javascript code follows:
function main(condition){ if(condition){ dosomething(); homecoming obj; } } now want refactor code rid of "if" statement. here want do
function main(condition){ var dosomethingandreturnobj = function(){ dosomething(); homecoming obj; } homecoming status && dosomethingandreturnobj(); } here need help. caller of main function expects homecoming value of "undefined" or obj. in refactored code,
return status && dosomethingandreturnobj();
convert homecoming value true , false type?
thanks replies.
javascript's && operator coalescing.
js> 0 && 7 0 js> 1 && 7 7 javascript
Comments
Post a Comment