Absrtact: The main purpose of this article is to help me to comb the context of JavaScript learning and use, most of it is only the collation of learning content, rather than original, I will post a reference link at the end of the article.
6 of the values in JavaScript are false
- False
- Null
- Undefined
- ‘‘
- 0
- NaN
The difference between = = = and = =
- = = =, do not type conversion, different types of certain range.
- "Unequal" if the types are different
- Type the same, and then judge
- = =, when the value types on both sides are different, type conversion is performed before comparison.
- If the two value types are the same, the = = = comparison.
- If two value types are different, they may be the same. The conversions are then compared according to the following rules:
A. If one is null and one is undefined, then "equal"
B. If one is a string, one is a numeric value, the string is converted to a value and then compared
C. If a value is Boolean, Boolean converts to a value of 1, and then compares
D. If one is an object and the other is a numeric or string, convert the object to the underlying type and then compare it. The object is converted to the underlying type, using its toString or ValueOf method. JS core built-in class, will try to valueOf before ToString, the exception is data, data is using the ToString conversion:
E. Any other combination, "unequal"
- Determines whether a value is NaN and can only be judged by IsNaN ()
= = = or = =
Should you use "= =" or "= = =" in JavaScript?
Reference
1. The difference between 2 equals and 3 equals sign in JavaScript
The type of JavaScript to judge (a) True and false