= = When data types are inconsistent on both sides of an expression, they are implicitly converted to the same data type, and then the values are compared.
= = = does not perform type conversions, and compares the data types on both sides, in addition to comparing values.
In addition, the value is null, "", when Undefined,nan, the return is also false. Sometimes it is not necessary to list out a line of code to solve the matter, do not write two lines.
Console.log (Boolean (null)); // false
Console.log (Boolean ("")); // false
Console.log (Boolean (undefined)); // false
Console.log (Boolean (NaN)); // false
Console.log (Boolean (1= =1)); // true
Console.log (Boolean (1= ="1")); // true
Console.log (Boolean (1= = =1)); // true
Console.log (Boolean (1= = ="1")); // false
Besides, the difference between null, Nan, and undefined is also seen from the code that runs below.
varA1;varA2 =true; vara3 = 1; vara4 = "a"; varA5 =NewObject ();varA6 =NULL; varA7 =NaN;varA8 =Undefined;console.log (typeof(a));//"undefined"Console.log (typeof(A1));//"undefined"Console.log (typeof(A2));//"Boolean"Console.log (typeof(A3));//"Number"Console.log (typeof(A4));//"string"Console.log (typeof(A5));//"Object"Console.log (typeof(A6));//"Object"Console.log (typeof(A7));//"Number"Console.log (typeof(A8));//"undefined"Console.log (Boolean (A1= = A6));//trueConsole.log (Boolean (a1 = = A7));//falseConsole.log (Boolean (a6 = = A7));//falseConsole.log (Boolean (a7 = = A7));//false
You can see that undefined values and definitions are not assigned to Undefined,null is a special Object,nan is a special number.
Undefined is equal to null, and Nan is not equal to any value, nor is it equal to itself.
The difference between equal (= =) and identity (= = =) in JS