Operator ==

1、null==underfined为true

Explain: js specification mentioned, with null underfined when compared for equality, a predetermined two are equal, and without any conversion (coding turtle!) .

Some say that is because underfined derived from null.

2, while a string, while a number, then the string into a number (Number The ()) then compared.

For example: "1" = 1 Essence: Number The ( "1") == 1 is true

3, while a Boolean value, if it is true, then a comparison is converted, if false, then converted to 0

For example: true == '1' essentially: Number (true) == Number ( "1") is true

4, while a string or a number, while the object, the object is converted to the original value (the base type), and then compared.

How to convert objects into basic types, you can see: https: //www.cnblogs.com/yanze/p/11442611.html

Guess you like

Origin www.cnblogs.com/yanze/p/11442514.html