What you’ll learn
- The different types of values in JavaScript
- Strings, quotes and escape characters
- Template literals (the easy way to build text)
- String methods like
toUpperCaseandincludes - Numbers, decimals, and the weird ones:
NaNandInfinity - Why
0.1 + 0.2isn't exactly0.3 - Booleans,
undefinedandnull - Converting between types (and JavaScript's surprise conversions)
The pages
Thirteen pages, about 17 minutes.
- The Kinds of Things in the Boxes In Grade 1, we put all sorts of things into our variable boxes: names, ages, prices. You might have noticed that some…
- Strings: Text in Quotes A string is a piece of text. It's called a "string" because it's a string of characters, one after another, like beads…
- Template Literals: The Easy Way to Build Strings In Grade 1, we built messages by gluing strings and variables together with +. It works, but all those + signs and…
- String Superpowers Strings come with a whole toolbox of built-in abilities. Let's look at the most useful ones. Every string knows its…
- Numbers The number type holds, well, numbers. Unlike some other languages, JavaScript doesn't care whether a number is whole…
- The Weird Numbers: NaN, Infinity and 0.1 + 0.2 Numbers are mostly well-behaved. But they have a few oddball relatives that show up at family gatherings and make…
- Booleans: True or False A boolean is the simplest type of all. It has only two possible values: true and false. That's it. Yes or no. On or…
- undefined and null: Two Kinds of Nothing JavaScript has not one, but two different values that mean "nothing." This confuses people, so let's clear it up…
- typeof: What's in the Box? Sometimes you want to know what type of value a variable is holding. JavaScript has a handy operator for that called…
- Type Conversion: Changing Types on Purpose Sometimes you have a value of one type, but you need it to be another type. The classic example is prompt, which…
- Type Coercion: JavaScript's Surprise Gifts When you mix different types in an operation, JavaScript doesn't throw an error. Instead, it quietly converts one of…
- Mini Project: The Message Analyzer Let's use our new string superpowers to build a little tool that analyzes a text message. Grade 2, done! You now know…
- Recap The key ideas of Grade 2, JavaScript data types, on one page. Every value has a type. The main ones are string…
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.