(1) The following three cases typeof return type is undefined
--When the variable is not initialized
--When a variable is not defined
--When the function has no explicit return value (undefined is returned when the function has no return value)
(2) Null type
Undefined is handled by a null derivation, so undefined = = NULL
Undefined is the variable declared but not initialized,
Null indicates an object that does not already exist.
(3) NaN value
is a special value that represents a non-number (not a digit), and the type conversion fails to return Nan
--nan is not equal to itself, that is nan = = Nan is False
--Judge Nan using IsNaN ();
(3) In fact, NULL, Nan, and undefined are the default initial values for variables. Different types of variables, the system gives the initial value is different:
--int,uint-0
--boolean-false
--number-nan
--string,array,object-null
--Unspecified variable type-undefined
<script>document.write (typeof (A1));//undefinedvar A2;document.write (typeof (A2));//undefinedvar a3=[]; document.write (typeof (A3));//objectvar a4={};d ocument.write (typeof (A4));//objectvar A5=null;document.write ( typeof (A5))//objectvar A6=document.getelementbyid ("Without this ID");d ocument.write (typeof (A6));//objectvar a7=new Object ;d Ocument.write (typeof (A7));//object</script>
(4) An interview topic about the object in JS (the core is to pay attention to the object's attribute name, and use the JS identifier (A and B) to make the property name directly converted to ["Object Object"], so all are the same):
For detailed analysis, see: Object creation, attribute access in JS
<script>var a=new object;var b=new object;var c=new object;c[a]=a;c[b]=b;alert (c[a]==a);//falsealert (C[a]===a) ;//falsealert (c[a]===b);//truealert (c[b]===b);//true</script>
<script>var a=new object;var b=new object;var c=new object;c["A"]=a;c["B"]=b;alert (c["a"]==a);//truealert (c["a "]===a");//truealert (c["a"]===b)//falsealert (c["B"]===b);//true</script>
Resources:
JS judge undefined type, undefined,null, the difference between the detailed analysis
The difference between Undefined,null,nan in JS
JavaScript undefined,null type and nan value differences
The difference between undefined, null, and Nan in JS, and the face question of assigning values to an object's properties