In Grade 1, we put all sorts of things into our variable boxes: names, ages, prices. You might have noticed that some values had quotes around them ("Mia") and some didn't (25). That's because they're different types of value.
Think about your kitchen. You've got liquids (water, juice, soup), solids (bread, fruit, yam), and spices. You treat them differently. You pour liquids. You slice bread. You sprinkle spices. You'd never try to slice a glass of water or pour a loaf of bread. (Please don't try.)
JavaScript values are the same. Each value has a data type, and the type decides what you can do with it. You can multiply two numbers, but what would it mean to multiply two names? You can make text uppercase, but what's an uppercase number?
Here are the types you'll use in JavaScript:
| Type | What it holds | Examples |
|---|---|---|
| String | Text | "hello", 'Paris', `Hi!` |
| Number | Numbers, whole or decimal | 42, -7, 3.14 |
| Boolean | Yes or no | true, false |
| Undefined | "No value has been given yet" | undefined |
| Null | "Deliberately empty" | null |
| BigInt | Really, really huge whole numbers | 9007199254740993n |
| Symbol | A unique identifier (advanced) | Symbol("id") |
| Object | Collections of values (lists, records, and more) | [1, 2, 3], { name: "Mia" } |
The first seven are called primitive types: simple, single values. The last one, object, is the big container type that we'll explore in Middle School (Grades 7 and 8).
Don't try to memorize this table. In this grade we'll focus on the five you'll use every single day: strings, numbers, booleans, undefined and null.