Short-circuits conditionals in javascript
If we need to execute a code when some condition is satisfied we generally do like the below code.
if(condition){
....
}
But this takes three lines of code in your source code to reduce that you can use a short-circuit like the below code
condition && sayhi()
The sayhi() function is executed only when the condition is evaluated to true.
var a = 10;
if(a > 5) {
// call a function
}
convert the above code to
var a = 10;
a > 5 && fnCall();