Home >Web Front-end >JS Tutorial >What are the data types returned by typeof
There are 6 data types returned by typeof, namely: 1. object, object type; 2. undefined, undefined type; 3. string, string type; 4. number, numeric type; 5. boolean, Boolean type; 6. function, function type.
typeof returns a total of 6 data formats:
1, object —Variables or values of object type, Or null (this is a problem left by JS history, treat null as the Object type)
2, UNDEFINED-Unfalted variables or values
3, String-String-string type variables Or value
4、number --Numeric type variable or value
5、boolean --Boolean type variable or value
6、function --Function type Variable or value
Example:
Undefined
var a1; typeof(a1);
Run result:
number
var num1=12; typeof(num1);
Run result:
string
var num2="12"; typeof(num2);
Run result:
boolean
var flag=true; typeof(flag);
Run result:
object
var str=new String(); typeof(str); var a=null; typeof(a);
Run result:
function
var fn = function(){}; typeof(fn); typeof(class c{});
Run result:
For more programming-related knowledge, please visit: Introduction to Programming! !
The above is the detailed content of What are the data types returned by typeof. For more information, please follow other related articles on the PHP Chinese website!