filmov
tv
15. JavaScript Logical Operators || (OR), && (AND), ! (NOT)

Показать описание
There are three logical operators in JavaScript: || (OR), && (AND), ! (NOT).
Although they are called “logical”, they can be applied to values of any type, not only boolean. Their result can also be of any type.
A chain of OR "||" returns the first truthy value or the last one if no truthy value is found.
AND returns the first falsy value or the last value if none were found.
The first NOT converts the value to boolean and returns the inverse, and the second NOT inverses it again. In the end, we have a plain value-to-boolean conversion.
Let's be friends: