var A1;var a2 = True;var a3 = 1;var a4 = "Hello"; var a5 = new Object (); var a6 = null;var a7 = nan;var A8 = Undefined;alert (typeof a); Show "undefined" alert (typeof A1); Show "undefined" alert (typeof A2); Displays "boolean" Alert (typeof A3); Show "number" alert (typeof A4); Displays "string" alert (typeof A5); Show "Object" alert (typeof A6); Show "Object" alert (typeof A7); Show "number" alert (typeof A8); Show "Undefined"
JS data types have undefined,boolean,number,string,object, such as 5, the first 4 are the original type, the 5th is the reference type.
First look at this example above, undefined values and definitions unassigned for Undefined,null is a special Object,nan is a special number (not a number).
var A1; The value of A1 is Undefinedvar a2 = Null;var a3 = nan;alert (A1 = = A2); Show "true" alert (a1! = A2); Show "false" alert (a1 = = A3); Show "false" alert (a1! = A3); Show "true" alert (a2 = = A3); Show "false" alert (a2! = A3); Show "true" alert (a3 = = A3); Show "false" alert (a3! = A3); Show "true"
From the above code, it can be concluded that (1) undefined is equal to NULL, and (2) Nan is not equal to any value, nor is it equal to itself.
Null is an object that represents a null pointer, undefinded is a type that is undefined, and its type is itself called "Undefined type" (and the difference between type object)
The difference between Nan, null, and undefinded in JavaScript