Recently, I have noticed, that putting an or operator between two functions, will make the second one run only if the first side of the operator is false. Is it safe to use this instead of if statements?
Example:
function a(){ return Math.random() >= 0.5; }
function b(){ console.log("foo"); }
Using
!a() || b();
has the same behaviour as
if( a() ) b();
My question is: Is it safe to use this syntax? Are there exceptions?