See short-circuit evaluation for the explanation. It’s a common way of implementing these operators; it is not unique to JavaScript.
More Related Contents:
- JavaScript OR (||) variable assignment explanation
- Multiple left-hand assignment with JavaScript
- How do JavaScript closures work?
- JavaScript check if variable exists (is defined/initialized)
- How can I determine if a variable is ‘undefined’ or ‘null’?
- Operator precedence with Javascript Ternary operator
- Why is the value of my input always empty if I store it in a variable?
- JavaScript check if variable exists (is defined/initialized)
- Set Webkit Keyframes Values Using Javascript Variable
- JavaScript loop variable scope
- Dynamic variables names in javascript
- What does variable declaration with multiple comma separated values mean (e.g. var a = b,c,d;)
- javascript pass object as reference
- Global variables in Google Script (spreadsheet)
- Variables set during $.getJSON function only accessible within function
- Destructuring assignment in JavaScript
- Dynamic object property names?
- how to access object property using variable [duplicate]
- In JavaScript, is chained assignment okay?
- Append to string variable [closed]
- Can a JavaScript object property refer to another property of the same object? [duplicate]
- Global variables in Javascript and ESLint
- How can I make a program wait for a variable change in javascript?
- Variable re-assignment of object reference leaves other object unaltered (no “transitive” assignment)
- What does [] mean in JavaScript?
- How to access a JavaScript variable from code behind in asp.net
- Why does accessing a non-existent object property result in `undefined` instead of throwing a `ReferenceError`?
- JSON to string variable dump
- What is the best method to convert floating point to an integer in JavaScript?
- Print / display a JavaScript variable’s name instead of it’s value