Objects, this and Classes

Stephen Gruppetta 22 Lessons 5h 47m Updated intermediate js

Mei keeps four houseplants on the shelf by her window: Goldie the pothos, Moss the monstera, Lily the peace lily, and Spike the cactus. Each one needs water on its own schedule.

Her plants start as plain records with separate functions that work on them, and nothing stops a stray line of code from giving Moss a watering interval of -7 days. In this course, you’ll turn those records into a tracker that tells Mei which plants need water today and refuses data that makes no sense.

Once an object holds its own behavior, the questions change. Which object does a method work on? Why does a method that works fine on its own fail when you pass it to forEach()? Who’s allowed to change the data? Answer those, and you can design objects that look after themselves. You’ll learn how to:

  • Give objects methods, and run your code in strict mode
  • Predict what this refers to from how a function is called, and keep it in callbacks
  • Build objects from a class, and follow the prototype chain behind them
  • Protect an object’s data with private fields, getters, and setters
  • Build Mei’s houseplant tracker, and explain how it works

Each of the first four sections mixes text lessons and short videos, and ends with an exercise you write in the browser, where automated tests check your code. You’ll run the lesson examples in your own terminal, in a small Node project.

In the project, you build Mei’s tracker in two steps. First, a Plant class keeps each plant’s day count in a private field, works out needsWater with a getter, and uses a setter to reject a negative watering interval.

Then a Shelf class holds her plants, lists the ones that need water with reminders(), and records each watering with waterPlant(). Along the way, Mei’s weekend-away script waters every plant with one line, and you make sure it does its job. Then you explain your tracker to the AI mentor, make a change the brief didn’t ask for, and take a quiz.

This course is for programmers who have finished JavaScript Basics and can write small Node programs with functions, arrays, and objects. The earlier intermediate courses on the path help, especially arrow functions as callbacks, closures, modules, and throwing errors. You’ll need a current Node LTS, a terminal, and any editor.

What’s Included:

  • 22 Lessons
  • Video Subtitles and Full Transcripts
  • Translated Subtitles in 8 Languages
  • 2 Downloadable Resources
  • Interactive Quiz to Check Your Progress
  • 6 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