In ECMAScript there are five simple data types (also called primitive types) and one complex datatype.

The simple data types are:

The complex data type is:

To determine the data type of a variable, the typeof operator may be used.

This is the list of possible returned values:

  • undefined;
  • boolean;
  • string;
  • number;
  • object;
  • function.

Although functions are considered to be objects due some differences in their properties the typeof operator distinguishes between them.

Example

The typeof operator example:

 

›› go to examples ››