JavaScript Basics
Data Types
Every value in JavaScript has a type.
| Type | Example | Description |
|---|---|---|
| String | "hello", 'hi' | Text |
| Number | 42, 3.14, -7 | Integers and decimals |
| Boolean | true, false | Yes or no |
| undefined | undefined | A variable with no value yet |
| null | null | Intentionally empty |
| BigInt | 9007199254740993n | Very large whole numbers |
| Object | { name: "Ali" } | Collections of values; arrays are objects too |
Checking a type
console.log(typeof "hi"); // "string"
console.log(typeof 42); // "number"
console.log(typeof true); // "boolean"
console.log(typeof undefined); // "undefined"
console.log(typeof { a: 1 }); // "object"
console.log(Array.isArray([])); // true