The Kinds of Things in the Boxes

Grade 2, page 1 of 13. A one-minute read.

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:

TypeWhat it holdsExamples
StringText"hello", 'Paris', `Hi!`
NumberNumbers, whole or decimal42, -7, 3.14
BooleanYes or notrue, false
Undefined"No value has been given yet"undefined
Null"Deliberately empty"null
BigIntReally, really huge whole numbers9007199254740993n
SymbolA unique identifier (advanced)Symbol("id")
ObjectCollections 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.

Reading is step one

CurlyScript turns these notes into a game: short questions, an explanation after every answer, and a test at the end of each grade. Free, with nothing to sign up for.

Start learning