Code highlights logo

JavaScript Data Types: A Comprehensive List

December 21, 2023
JavaScript Data Types: A Comprehensive List
Table of Contents
  • Primitive Data Types
  • 1. Numbers
  • 2. Strings
  • 3. Booleans
  • 4. Null
  • 5. Undefined
  • 6. Symbols
  • Object Data Types
  • Conclusion

JavaScript is a dynamically typed language, meaning that data types are determined at runtime based on the assigned values. This can lead to some confusion, especially for beginners. In this article, we will cover the different data types in JavaScript and their properties.

Primitive Data Types

JavaScript has six primitive data types, which are immutable (cannot be changed). They are:

1. Numbers

Numbers represent both integer and floating-point values. They are denoted using the number keyword.

1const age = 25; // integer
2const price = 9.99; // floating-point


  • MAX_VALUE: The maximum representable number in JavaScript
  • MIN_VALUE: The smallest positive representable number in JavaScript
  • NEGATIVE_INFINITY: Represents negative infinity
  • POSITIVE_INFINITY: Represents positive infinity
  • NaN: Not a number

2. Strings

Strings represent text and are denoted using the string keyword. They can be enclosed in single or double quotes.

1const name = "John";
2const message = 'Hello, world!';


  • length: Returns the length of the string

3. Booleans

Booleans represent the truth values true and false and are denoted using the boolean keyword.

1const isOnline = true;
2const isLive = false;

4. Null

Null represents the intentional absence of any object value and is denoted using the null keyword.

1const user = null;

5. Undefined

Undefined represents the absence of any value and is denoted using the undefined keyword. It is typically used for uninitialized variables or missing object properties.

1let age;
2console.log(age); // undefined

6. Symbols

Symbols represent unique identifiers and are denoted using the symbol keyword. They are typically used as property keys in objects.

1const key1 = Symbol();
2const key2 = Symbol("description");

Object Data Types

The seventh data type in JavaScript is objects, which are mutable and can contain any combination of primitive and object values. They are denoted using curly braces {} and their properties are specified using key-value pairs.

1const person = {
2 name: "John",
3 age: 25,
4 isOnline: true


  • Object.keys(): Returns an array of object keys
  • Object.values(): Returns an array of object values
  • Object.entries(): Returns an array of key-value pairs


Knowing the different data types in JavaScript is essential for writing high-quality code. Understanding their properties and usage will help you avoid common programming errors and improve your productivity.

Stay Ahead with Code highlights

Join our community of forward-thinkers and innovators. Subscribe to get the latest updates on courses, exclusive insights, and tips from industry experts directly to your inbox.

3D Letter

Start learning for free

If you've made it this far, you must be at least a little curious. Sign up and grow your programming skills with Code Highlights.

Start learning for free like this happy man with Code Highlights