js parsing operation result two expressions:!! [] == [] == {} and {}

 []==![] 

1. an exclamation point! ! Highest priority, and therefore the first calculation [], which evaluates to false, so the expression is converted to: [] == false.
3. encountered Boolean type, need to be converted into a Number type, it is the expression becomes [] == 0
4.0 is the base type, [] is a reference type, it must be converted to a reference type base type: [] is the result of the conversion ([]) valueOf () toString (), as "", so the expression of " "== 0
The string needs to be converted into Number, is zero.
6. The result is 0 == 0. 
7. The final result is true.
 
{}==!{}
 
1. an exclamation point! ! Highest priority, and therefore to calculate {}, which evaluates to false, so the expression is converted to: {} == false.
3. encountered Boolean type, need to be converted into a Number type, it is the expression becomes [] == 0
4.0 is the base type, {} is a reference type, the reference type must be converted to the base type:
    {} Is the result of the conversion ({}). ValueOf (). ToString (), as "[object Object]", so the expression of "[object Object]" == 0
The string needs to be converted into Number, is NaN.
6. The result is a NaN == 0. 
7. The final result is false.

Guess you like

Origin www.cnblogs.com/0xMe/p/11441104.html