JavaScript Data Types
JavaScript has two main types:
Primitive and Non-Primitive (Reference).
Primitive Data Types - These store single values and are immutable.
Data Type | Description | Example |
---|---|---|
String |
Text data | "Hello" |
Number |
Numeric values |
42 , 3.14
|
Boolean |
True or false |
true , false
|
Null |
Intentional empty value | null |
Undefined |
Variable not assigned | undefined |
BigInt |
Large integers | 12345678901234567890n |
Symbol |
Unique identifier | Symbol("id") |
Non-Primitive (Reference) Data Types - These store collections or complex data.
Data Type | Description | Example |
---|---|---|
Object |
Key-value pairs | { name: "Vasanth", age: 25 } |
Array |
List-like objects | [1, 2, 3] |
Function |
Reusable blocks of code | function greet() {} |
These are the data types used in JavaScript. I will explain each of them in detail in upcoming posts.
Top comments (0)