react Does JavaScript have “Short-circuit” evaluation?



short circuit evaluation react (1)

Possible Duplicate:
Using &&'s short-circuiting as an if statement?
Does javascript use optimization in boolean expressions?

I would like to know if JavaScript has "Short-circuit" evaluation like && Operator in C#. If not I would like to know if there is a workaround that makes sense to adopt.

https://code.i-harness.com


Yes, JavaScript has "short-circuit" evaluation.

if (true == true || foo.foo){
    // Passes, no errors because foo isn't defined.
}

Live DEMO

if (false && foo.foo){
    // Passes, no errors because foo isn't defined.
}

Live DEMO





short-circuiting