20%
Instructions
Data Types 🏷️
JavaScript has several built-in data types to represent different kinds of information.
Primitive Types
| Type | Example | Description |
|---|---|---|
string | "Hello" | Text |
number | 42, 3.14 | Numbers (both integer and decimal) |
boolean | true, false | Logical values |
undefined | undefined | No value assigned |
null | null | Intentionally empty |
typeof Operator
Use typeof to check a value's type:
console.log(typeof "Hello"); // "string"
console.log(typeof 42); // "number"
console.log(typeof true); // "boolean"
💡 Did You Know? Unlike many languages, JavaScript uses a single
numbertype for both integers and decimals.
Your Turn!
Print the typeof the number 2024.
Help
Data TypesExercise 3/10 • 15 XP
❴❵ script.js
Terminal