Data types

Every variable has a data type. Data type indicates what kind of data the variable holds. In JavaScript, the type of data variable hold can be grouped into two categories:

  1. primitive types
  2. composite types

Primitive types in JavaScript

JavaScript supports five primitive data types:

  1. numbers
  2. strings
  3. Booleans
  4. undefined and null

From these basic data types, more complex data type (also known as composite types) is derived. Although JavaScript supports five primitive data types, we actually use only numbers, strings, and Booleans to store data. The undefined and null types arise under certain circumstances in programming.

Composite types in JavaScript

From primitive types mentioned above, we can derive composite types. A composite type can consist of numbers, strings, Booleans, undefined and null values. The three types of composite types available in JavaScript are objects, arrays, and functions.