ajhsu / blog

The external storage of my brain.
3 stars 0 forks source link

The simplest explanation of || and && operator #12

Open ajhsu opened 7 years ago

ajhsu commented 7 years ago
The || operator returns the left-most truthy operand. 
If no truthy operand is provided, it returns the right-side operand.
The && operator returns the right-most falsy operand. 
If no falsy operand is provided, it returns the right-side operand.

Quoted from first of first comment of this article: http://www.codereadability.com/javascript-default-parameters-with-or-operator/