Skip to content
Announcing the new Pro Zone. Check it out!

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.

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.

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.