I have come across some Javascript code recently that looks like this:
var foo = 'blah';
bar = function(){
// append some content to the body
}
doStuff = function(){
if(somethingIsTrue){
// do something
} else {
// do something else
}
foo && bar();
}
doStuff();
The foo && bar() expression logs to the console as 'undefined'.
I get why it might call the bar function to run from inside the doStuff function but why is it used as a comparison expression with the foo variable?