JavaScript Data Types

Primitive Data Types

Definition: Primitive data types are the basic data types in JavaScript. They hold a single value and are immutable.

Data Type Description Example
String Textual data let name = "Rohan";
Number Numeric values let age = 25;
Boolean True or False let isOnline = true;
Undefined Variable declared but not assigned let x;
Null Intentional absence of value let y = null;
Symbol Unique and immutable value let id = Symbol("id");
BigInt Large integers let big = 123456789123456789n;

Non-Primitive (Reference) Data Types

Definition: Non-primitive data types can store collections of values or more complex entities and are mutable.

Data Type Description Example
Object Key-value pairs let person = { name: "Rohan", age: 25 };
Array Ordered list of values let fruits = ["apple", "banana"];
Function Reusable block of code function greet() { alert("Hello"); }