I want to ask about optimisation in JavaScript if else statement.I have the code like this
if ( thisIsTrue )
printMe("someMessage");
And the code can be optimisation like this
thisIsTrue && printMe("someMessage");
The question is what the code of thisIsTrue && printMe("someMessage"); only works in statement who has been return true.
What if the return is false?
!thisIsFalse && printMe("someMessage"). However, this is not really an optimization; all it does is make the code more difficult to read. I would go with your first example, and add braces too.