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

Popular posts from this blog

java - How to pass parameters between Request-Scoped Controllers? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -

string - what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++? -