Search code examples
javascriptshort-circuiting

JavaScript; parsing an IF statement with OR clauses


My question is quite simple, if I declare an IF statement with a series of OR clauses will JavaScript read all of the ORs or stop at the first one that is satisfied?

Thanks in advance.


Solution

  • Stops at the first one. It's called short-circuiting

    http://en.wikipedia.org/wiki/Short-circuit_evaluation https://developer.mozilla.org/en/JavaScript/Reference/Operators/Logical_Operators