References: Two Names, One Object

Stephen Gruppetta 21 Lessons 4h 48m Updated intermediate js

The Okafor family plans their meals a week at a time, and next week is always last week with a few changes. Two dinners swap, Friday’s takeout pizza goes, and a new recipe, egusi soup, comes in. Last week has to stay exactly as it was, but a quick copy of last week can quietly change it too. In this course, you’ll find out why, and build a planner that gets it right.

In JavaScript, a name doesn’t hold an array or an object. It points at one, and two names can point at the same one. Once you can see those arrows, you can predict which changes reach the original and write updates that leave it untouched. You’ll learn how to:

  • Copy and edit arrays with .slice() and .splice(), and predict when two names share one array or object.
  • Make shallow copies with spread and .slice(), and tell which parts of a copy are still shared.
  • Write functions that change a caller’s data only on purpose, with names that say so.
  • Compare records by identity with === and by their contents.
  • Unpack arrays and objects with destructuring, in variables and in function parameters.
  • Merge records with spread, gather arguments with rest parameters, and use copying array methods like .toSorted() and .with().
  • Update nested data by copying every level on the path and sharing the rest.

Each section mixes text lessons and short videos, and ends with an exercise you write in the browser, where automated tests check your code.

In the project, you build the Okafor family’s meal planner. It makes next week from last week, swaps two dinners, replaces Friday’s takeout, adds egusi soup, and lists the days that changed, while last week stays as it was. Then you explain to the AI mentor which parts of next week are new and which are shared, and take a quiz.

This course is for programmers who can write basic programs in Node, with functions, loops, arrays, objects, and lists of records, and who can hand arrow functions to array methods like .map() and .filter(). You’ll need a current Node LTS, a terminal, and any editor.

What’s Included:

  • 21 Lessons
  • Video Subtitles and Full Transcripts
  • Translated Subtitles in 8 Languages
  • 2 Downloadable Resources
  • Interactive Quiz to Check Your Progress
  • 5 Hands-On Coding Exercises
  • Q&A With JavaScript Experts: Ask a Question
  • Certificate of Completion

Downloadable Resources:

Related Learning Paths:

About Stephen Gruppetta

Stephen obtained a PhD in physics and worked as a physicist in academia for over a decade before becoming a programming educator. He's constantly looking for simple ways to explain complex things.

» More about Stephen

Each tutorial at RealJS is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

← Browse All Courses