Skip to main content

Data Types in JavaScript – What Values Can Variables Hold?

JavaScript data types refer to the kind of values you can assign to JavaScript variables.

There are two main value types in JavaScript: primitive and non-primitive.

Primitive Data Types

JavaScript has seven primitive values:

  • Number
  • String
  • Boolean
  • Undefined
  • Null
  • Symbol
  • BigInt

See the primitive data type page to learn more about JavaScript's primitive values.


A primitive data is also called a basic value.

Non-primitive Data

JavaScript has only one primitive data type:

  • Objects

See the non-primitive data type page to learn more about JavaScript's non-primitive value.


A non-primitive data is also called a complex value.

Important Stuff to Know about Data Types in JavaScript

JavaScript is a loosely and dynamically typed language. Therefore, you can use the same variable to store different value types.

Here's an example:

let teaTime = false; // teaTime is currently a Boolean
teaTime = 7; // teaTime is now a Number
teaTime = "Seven"; // teaTime is now a String

The snippet above first used the teaTime variable to store a Boolean value.

Then, we changed teaTime from a Boolean to a Number.

Afterward, the variable got changed to a String data type.

In other words, you can use the teaTime variable to store any data type because JavaScript is a weakly and dynamically typed language.


Among the eight types of values that you can store in a JavaScript variable, seven are primitives, while only one is non-primitive.