Does JavaScript have "Short-circuit" evaluation?
javascript, short-circuiting
Solution
Yes, JavaScript has "short-circuit" evaluation.
if (true || foo.foo){
// Passes, no errors because foo isn't defined.
}
Live demo
if (false && foo.foo){
// Also passes, no errors because foo isn't defined.
}
Live demo
Problem
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.