Data Types in JavaScript

Data Types in JavaScript

strings, numbers, booleans, undefined, bigint, null, and symbols


2 min read

Play this article

When you work with JavaScript, you encounter various data types that allow you to store and manipulate different kinds of information. Understanding these data types is fundamental to effective programming in JavaScript. In this blog post, we'll explore the common data types in JavaScript, including strings, numbers, booleans, undefined, bigint, null, and symbols.


A string is a sequence of characters enclosed within single (' '), double (" "), or backticks (` `) quotes. Strings are used to represent text and are one of the most frequently used data types in JavaScript.


let greeting = "Hello, World!";


Numbers in JavaScript can be integers or floating-point numbers. You can perform mathematical operations like addition, subtraction, multiplication, and division using number data types.


let age = 25;
let price = 9.99;


A boolean represents a logical value and has only two possible values: true or false. Booleans are often used for making decisions in your code, such as in conditional statements.


let isTrue = true;
let isFalse = false;


In JavaScript, a variable that has been declared but not assigned a value, automatically gets the undefined data type. It indicates the absence of a meaningful value.


let name;
console.log(name); // Outputs: undefined


The bigint data type is used to represent large integers that cannot be accurately represented using the standard number data type. This is used to store numbers that are bigger than the normal range of Number data type. BigInts are created by appending n to the end of an integer literal or by calling the BigInt() constructor.


const bigIntValue = 1234567890123456789012345678901234567890n;


The null data type represents the intentional absence of any object value or a variable that has no value. It does not mean zero.


let emptyValue = null;


A symbol is a unique and immutable data type introduced in ECMAScript 6 (ES6). Symbols are often used as object property keys to prevent unintentional name collisions.


const uniqueSymbol = Symbol("description");
const obj = {
  [uniqueSymbol]: "This is a unique symbol key",

In conclusion, JavaScript offers a variety of data types to work with different kinds of information. Understanding these data types and how to use them is essential for writing effective and error-free JavaScript code.