In JavaScript! =, = ,! The usage and difference of ====.
var num = 1; var str = '1'; var test = 1; test == num // True; same type; Same Value test === num // True; same type; Same Value test !== num // False test and num are of the same type, and their values are the same. Non-calculation is certainly false. num == str // True converts str to a number and checks whether it is equal. num != str // Non-operation with false = num === str // If the type of false is different, false is returned directly. num !== str // True num and str are of different types, which means they are not equal to each other. The non-operation is true.
= And! = If the comparison type is different, first try the conversion type, then compare the value, and finally return the comparison result.
While
===And! = The value is compared only in the same type. (Compare when values and types are the same)
=, When the value types on both sides are different, type conversion should be performed first and then comparison should be made.
===, No type conversion is required. The types may vary.