|| Shouldn’t the operator return true or false? Why does JavaScript return an object? What’s going on? Could you please help me explain
三叔2017-06-12 09:31:40
Javascript logical operatorscan be used in non-Boolean environments.
Although the && and || operators can be used in non-Boolean environments, if their return values can be converted to Boolean values, they can also be considered Boolean operations
(from logical operator)
For non-Boolean environments:
When there is one false, return the value on the false side
When there are two false, return the value before the operator (left side);
When there are two true, return the value after the operator (right side) value.
(derived from the return value of logical operations in JavaScript (logical AND &&, logical OR ||, logical NOT!))
学习ing2017-06-12 09:31:40
First of all, you need to know the false values in js: 0, false, '', null, undefined, NaN
In combination or operation
When one.nextElementSibing is not any of the above values, next = one.nextElementSibing; otherwise it is equal to one. nextSibing