Last Updated: February 25, 2016
·
640
· ytilis

Short Circuits in Javascript

Remember, Javascript, like most languages, short-circuits when dealing with if statements.

What does that mean?

Well for example, when running an OR evaluation with two functions, such as

if( doThis(var1) || doThat(var2) ){
    alert("Woot!");
}

If the first function is true, the second function will not execute.

Something to keep in mind for future reference if you’re wondering why your function’s not running.

Written by Yury Tilis

Recommend
Say Thanks
Update Notifications Off
Respond