First of all, == equality is equal, === identity is equal.
==, when the value types on both sides are different, type conversion must be performed first and then compared.
===, no type conversion is performed, and different types must not be equal.
The following are respectively explained:
Let’s talk about === first, this is relatively simple. The following rules are used to determine whether two values are === equal:
1. If the types are different, [not equal]
2. If both are numeric values and are the same value, then [equal]; (!Exception) is that if at least one of them is NaN, then [not equal]. (To determine whether a value is NaN, you can only use isNaN() to determine)
3. If both are strings and the characters at each position are the same, then [equal]; otherwise [not equal].
4. If both values are true, or both are false, then [equal].
5. If both values refer to the same object or function, then [equal]; otherwise [not equal].
6. If both values are null, or both are undefined, then [equal].
Let’s talk about ==, according to the following rules:
1. If two value types are the same, perform === comparison.
2. If two value types are different, they may be equal. Perform type conversion and comparison according to the following rules:
a. If one is null and the other is undefined, then [equal].
b. If one is a string and the other is a numerical value, convert the string into a numerical value and then compare.
c. If any value is true