Difference = = = = = and && type conversion (implicit call) - to analyze. / / = = equal, compare the value of the / / = = = are congruent, Comparison types also compare values undefined, NaN, 0, null and empty string '',false is treated as false // numeric string Boolean undefined null // 0 "" false undefined null NaN(abnormal value) // true // "5" == 5 // false // console.log(false == 1); // false // console.log(false == [1]); // false // equality comparison rule: NaN is not equal to any value, including NaN itself. Null is not equal to any value, except null and undefined // 3. Undefined is not equal to any value. // 4. If the operands are Boolean or numeric, convert them to numeric values for comparison. If one of the operands is a string, convert the operands to a string for comparison. If both sides of the operands are complex data types, compare the address // console.log("5" == 5); // +"5" // console.log(false == 1); // +false ==> 0 // console.log(false == "1"); // 0 == 1 ===> false // console.log(false == "0"); // true // console.log(false == null); // false // console.log(false == undefined); // false // console.log(null == 0); // console.log(null == false); // console.log(null == undefined); // console.log(null === undefined); // false // console.log(undefined == 0); // console.log(undefined == ""); // console.log(NaN == 0); // console.log(NaN == NaN); // console.log({} == {}); // false // console.log([]==[]); // false // console.log(undefined == null); // console.log([] == ! []); // true // console.log([] == false); // +[] ==> 0 +false ==> 0 0 == 0 // ! The operator takes precedence over the comparison operator //! // [] true {} true "123" "0" //! [] ==> false // How to quickly convert Boolean types!! Boolean type //! // console.log({}==! {}); // false // start with the right unary operator:! If ({} => false) {} => 0; if ({} => 0) {} => 0; ToString () => "[object object]" example 1: var obj = {}; // console.log(obj.toString()); / / "[objectObject]" case 2: / var/a = {}, / / b = {key: 'b'}; // c = {key: 'c'}; // a[b] = 123; // a[c] = 456; // console.log(a[b]); // 1. // 2. // 1. NaN // 2. Null // 3. There is a Boolean, numbers ==> are converted to numbers // 5. // NaN: not a number //2. This is actually a bad conversion method, browser tolerance, do not give error, //5. IsNaN determines whether the content of a value is a number (content '3' 3) // If the content is a number => false console.log( isNaN(3) ); //false console.log( isNaN('4') ); //false console.log( isNaN('abc')); //true thinking: // console.log({}==! []); // console.log(! [] = = {}); // console.log([]==! {});Copy the code