Includes the = = and = = = Operators, the former is lenient judgment equality, if the two types are different before the comparison value will be type conversion, the latter is a complete equality determination.
1, numeric, string, and Boolean values by value comparison
= = = = = Whether the two are identical before and after detection, only if they hold the same values exactly.
var a = ' a ';
var b = ' a ';
Console.log (A==B,A===B);
True True
var a = String (' a ');
var B = String (' a ');
Console.log (A==B,A===B);
True True
JS numbers are floating point number, there is no problem of integral type to floating point type
var a = 1;
var B = 1.0;
Console.log (A==B,A===B);
True True
var a = 1;
var B = true;
Console.log (A==B,A===B); = = before a type conversion, to a Boolean value
True False
2. Use reference comparisons between objects, arrays, and functions.
Arrays and functions are special forms of objects.
If objects have different storage addresses, they are not equal.
var a = [2,3];
var b = [2,3];
Console.log (A==B,A===B);
False false
var a = [2,3];
var B = A;
Console.log (A==B,A===B);
True True
3. Special Nan
Nan is not equal to any numeric, object comparison, including itself.
var a = 2;
var B = 0/0;
Console.log (B,a==b,a===b,b==nan);
NaN false False
4. Comparison of NULL and undefined
The comparison of these two basic types is the same as for numbers and strings.
var a = null;
var b = undefined;
var D;
Console.log (d,a==b,a===b,b===d,d===undefined);
Undefined true true false true
5. Comparing objects to strings
JS internally converts the object to a value of the original type, usually first trying the valueof method before attempting the ToString conversion.
var a = ' [Object Object] ';
var b = {};
Console.log (A==b,b.tostring ());
True [Object Object]
The only exception is the core object date in JS, which is converted directly using the ToString () method.
var a = new Date (2016,04,15);
var B = 1463241600000;
var c = ' Sun may 00:00:00 gmt+0800 ';
Console.log (A==b,a==c,a.valueof (), a.tostring ());
False true 1463241600000 Sun may 00:00:00 gmt+0800
JavaScript basics: Equals sign comparison