JS Data Types
JavaScript variables can hold different data types: strings, numbers, booleans, objects, arrays, and more.
JavaScript is dynamically typed — a variable can hold any type of data, and the type can change at runtime. Use typeof to check any variable’s type.
Try It — All Data Types
Preview
Data Types at a Glance
| Type | Example | typeof result |
|---|---|---|
| String | "Hello" | "string" |
| Number | 42, 3.14 | "number" |
| Boolean | true, false | "boolean" |
| Undefined | let x; | "undefined" |
| Null | null | "object" (JS quirk) |
| Object | { key: value } | "object" |
| Array | [1, 2, 3] | "object" |
Tip: Arrays are technically objects in JavaScript. Use
Array.isArray(value)to reliably test if something is an array.