Last Updated: February 25, 2016
·
845
· 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.

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Related Tags
#javascript
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside