arranging the conditions in the "if" statement. If you have several
conditions to be tested together, and you know that one is more likely to
pass or fail than any of the others, depending on whether the tests are
connected with OR (||) or AND (&&), you can speed execution of your script
by putting that condition first in the conditional statement.
For example, if three conditions must all be true (using && operators) and
the second test fails, the third condition is not tested. Similarly, if
only one of several conditions must be true (using || operators), testing
stops as soon as any one condition passes the test. This is particularly
effective if the conditions to be tested involve execution of function calls
or other code.
In this example, the second part of the condition will not be evaluated
if the first part of condition returns true. Notice that in this
case it will save you a function call.
if ((firstfunction() == true) || (secondfunction() === true))