JavaScript Internals (521 Qs)•Part 7: Execution Context, Functional JS & V8 Engine (404 - 463)
What is a Short circuit condition
Short circuit conditions are meant for condensed way of writing simple if statements. Let's demonstrate the scenario using an example. If you would like to login to a portal with an authentication condition, the expression would be as below,
javascript
if (authenticate) {
loginToPorta();
}
Since the javascript logical operators evaluated from left to right, the above expression can be simplified using && logical operator
javascript
authenticate && loginToPorta();