In JavaScript, typeof is an operator used to detect the Data Type of a given variable. typeof is used to detect the Data Type of the following variable.
Example:
VaR m; var M1 = "hi"; var m2 = 2; var m3 = true; var M4 = function () {}; var M5 = new object (); vaR M6 = NULL; alert ("typeof M type:" + typeof m + "\ n \ r" + "typeof M1 type: "+ typeof M1 +" \ n \ r "+" typeof M2 type: "+ typeof M2 +" \ n \ r "+" typeof M3 type: "+ typeof m3 +" \ n \ r "+" typeof M4 type: "+ typeof M4 +" \ n \ r "+" typeof M5 type: "+ typeof M5 +" \ n \ r "+" typeof M6 type: "+ typeof M6 +" \ n \ r "+" typeof M7 type: "+ typeof M7 );
View results
Running result: When a variable is declared with VAR but not initialized, the value of the variable is undefined.
The variable value that is not declared is also undefined.
The data type of a null variable is of the object type, because the null value indicates a null object pointer.