4 ms·
agreed, if (a) then just return a; if (a) { return true; } is just as redundant as an if (a == true) statement.
by RWilson 18y ago
agreed, if (a) then just return a;
if (a) { return true; } is just as redundant as an if (a == true) statement.
- RWilson 18y agoHmm... not sure what justified the -1 on this. Perhaps that in some languages if (a) can be used as a shortcut for if (a != null), where a is an object and not a boolean. So, as a correction to my previous comment. If (typeof a == "Boolean" || a instanceof boolean), I still stand by reducing redundancy, but if a is an object, then fine, if (a) return true;