What you’ll learn
- What objects are and when to use them
- Creating objects with keys and values
- Dot notation vs bracket notation
- Adding, changing and deleting properties
- Methods, and a first look at
this - Nested objects and arrays of objects
- Looping over objects
- Destructuring and shorthand
- Copying objects (and the reference trap)
- JSON: objects as text
The pages
Thirteen pages, about 15 minutes.
- What Is an Object? Arrays are brilliant for lists of similar things: a list of names, a list of scores, a list of foods. But what if you…
- Creating Objects You create an object with curly braces { }. Inside, you write key: value pairs, separated by commas. (Node prints…
- Reading Properties: Dot and Bracket Notation There are two ways to read a property from an object. The most common way is the dot: write the object's name, a dot…
- Adding, Changing and Deleting Properties Objects are flexible. You can change them any time, even if they were created with const (remember: const locks the…
- Methods: Functions Inside Objects Remember that functions are values (Grade 6)? That means a property's value can be a function. When a function lives…
- A First Look at this Methods often need to use the other properties of their own object. For example, a method that introduces a person…
- Nested Objects and Arrays of Objects Objects can contain other objects and arrays. And arrays can contain objects. You can nest them as deeply as you like…
- Looping Over Objects What if you want to go through every property of an object? Here are your options. The for...in loop visits every key…
- Shortcuts: Shorthand and Destructuring Modern JavaScript has a couple of lovely shortcuts for working with objects. If you're making an object from variables…
- Copying Objects (and the Reference Trap) In Grade 7, you saw that assigning an array to a new variable doesn't copy it. Objects work exactly the same way…
- JSON: Objects as Text Objects live in your program's memory. But what if you want to save an object to a file, or send it across the…
- Mini Project: The Report Card Generator Let's put objects, arrays, functions and loops together into something genuinely useful: a program that generates…
- Recap The key ideas of Grade 8, JavaScript objects, on one page. An object stores data as key: value pairs called…
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.