Haven't been paying attention to this operator that is constant equal to (three equals: = = =). Later in the actual work encountered, just want to know what is equal and constant equals what is the difference.
JavaScript is a weakly typed language, which means that the equals operator enforces type conversions in order to compare two of values. Note the equality operation for 0, for example:
JS Code
- "= =" 0 "//False
- 0 = = ""//True
- 0 = = "0"//True
- False = = "false"//False
- false = = "0"//True
- false = = undefined//False
- false = = NULL//False
- NULL = = undefined//True
- "\t\r\n" = = 0//True
Instead of the normal equals operator, the coercion type conversion is not performed. In this case, the results are not quite the same:
JS Code
- "" = = = "0"//False
- 0 = = = ""//False
- 0 = = = "0"//False
- false = = = "false"//False
- false = = = "0"//False
- false = = = undefined//False
- false = = = NULL//False
- NULL = = undefined//False
- "\t\r\n" = = = 0//False
The object, when used as constant equals, is used to determine whether the same object is equal to the judgment value. So, pay attention to it later. Try to use constant equals when judging, so you don't have to make a forced conversion comparison
[to] the difference between = = = (equals) and = = = (constant equals) in JavaScript