1. Type Analysis:

There are five types of data in JS: String, number, Boolean, undefined, object, the first four value types (basic data types), object is a reference type

        var a1; //undefined         var a2=10; //number         var a3="hello"; //string         var a4=true; //boolean         var a5=new Object(); //0bject         var a6=NaN; //number         var a7=null; //object         var a8=undefined; //undefinedCopy the code

Conclusion: Undefined value and undefined data type is undefined, NULL is a special object, NaN is a special number

2. Comparison operation

    var a1; // the value of a1 is undefined     var a2 = null;     var a3 = NaN;     alert(a1 == a2); // display "true"     alert(a1 ! = a2); // display "false"     alert(a1 == a3); // display "false"     alert(a1 ! = a3); // display "true"     alert(a2 == a3); // display "false"     alert(a2 ! = a3); // display "true"     alert(a3 == a3); // display "false"     alert(a3 ! = a3); / / show "true"Copy the code

Conclusion: undefined is equal to null; NaN is not equal to any value, nor to itself

3.Undefined data type: Undefined property is used to store JS Undefined value

    3.1 Return undefined: Object attribute does not exist; Variables are declared but never assigned.   3.2 You cannot use a for/in loop to enumerate undefined properties, nor can you use the delete operator to delete     3.3 Undefined is not a constant and can be set to another valueCopy the code

Null data type: Null has only one value in JS

    4.1 The keyword null cannot be used as the name of a function or variable     4.2 Variables that contain NULL contain "no value" or "no object", that is, the change does not hold a valid number, string, Boolean, array, or object     4.3 You can empty the contents of data by assigning a null value to a variable.   4.4 Null typeOF returns objectCopy the code

5. Null vs. undefined

    5.1 NULL is the keyword. Undefined is an attribute of the Global object.   5.2 NULL is an object (an empty object without any properties or methods); Undefined is a value of the undefined type.   console.log(typeof null); //return object     console.log(typeof undefined); //return undefined     5.3 In the Object model, all objects are instances of Object or its subclasses, except null objects.   console.log(null instanceof Object); //return false (check if it is an object)     5.4 null "equivalent ==" undefined, null == "undefined";   console.log(null == undefined); //return true     console.log(null === undefined); //return false     5.5 Null and undefined can be converted to false, but not equivalent to false &emsp.   console.log(! null, ! undefined); //true,true     console.log(null==false); //false     console.log(undefined==false); //falseCopy the code