The operator JS study notes

Operator: from left to right operation
Assignment operator: operator from right to left
 

The logical operators && ||!
&&
Fake encounter to return to the previous, full of real returns last
注:undefined, null, NaN, "", 0, false -> false
a && b && c - -> a is true, it is judged whether b is true, true, return the value of c
                        - -> a is true, determining whether b is true, false, or a value b
                        - -> a false return value of a 
It can be used as a short-circuit statement
was data = ...;
Statement data && execution of a will use data -> If the data is true, the statement following the implementation
 
||
True to return to the previous encounter, full of false returns last
a || b || c -> a is true, a return
                        -> a is false, it is determined whether b is true, true, return the value of b
                        -> a is false, b judge whether true, false, or the value of c -> as long as one is true, the result is true, for that, you have to condition before the end of programming, for judgment the conditions inside, at least there will be a true
-> fake encounter, on the back judge until you find a genuine, it will be returned, if the penultimate are false, it returns the last value 
As a compatible
 
! a -> first converted to a Boolean value, and then negated
! ! a -> converted to a Boolean value
 

Guess you like

Origin www.cnblogs.com/seveinn/p/11801671.html