Possible Duplicate:
Should ‘else’ be kept or dropped in cases where it’s not needed?
When
a = 0
This:
var foo = function() {
if (a != 0) return true
return false
}
Or this:
var bar = function() {
if (a != 0) return true
else return false
}
It gets optimized at compile time anyway, so no runtime difference.
As usual, you can argue about style. My 50 cents: the first variant (no explicit else) is nicer because it’s less code doing exactly the same.
Of course, in this case, you would do
… but I think the question is meant to be general.