Home > Web Front-end > JS Tutorial > What are the data types returned by typeof

What are the data types returned by typeof

青灯夜游
Release: 2020-11-11 14:43:07
Original
17843 people have browsed it

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.

What are the data types returned by typeof

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);
Copy after login

Run result:

What are the data types returned by typeof

number

var num1=12; 
typeof(num1);
Copy after login

Run result:

What are the data types returned by typeof

string

var num2="12"; 
typeof(num2);
Copy after login

Run result:

What are the data types returned by typeof

boolean

var flag=true; 
typeof(flag);
Copy after login

Run result:

What are the data types returned by typeof

object

var str=new String();
typeof(str);
var a=null; 
typeof(a);
Copy after login

Run result:

What are the data types returned by typeof

function

var fn = function(){};
typeof(fn); 
typeof(class c{});
Copy after login

Run result:

What are the data types returned by typeof

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template