SKU // 48

Objects: The Path

So far most of your variables have held one thing: a number, a string, a boolean. Real-world things have many details. A student has a name, a grade, an ID, and a schedule. An object bundles all of those details together under one name.

// The Problem Objects Solve

// Without objects: loose variables that only belong together by naming
let studentName  = "Riley";
let studentGrade = 10;
let studentGPA   = 3.6;

// With an object: one thing, with named parts
const student = {
  name: "Riley",
  grade: 10,
  gpa: 3.6
};

console.log(student.name);
Riley

Now you can pass the whole student to a function, store thirty students in a list, or add a new detail without inventing another variable name.

// Objects Are Everywhere

You have been using objects all along without writing your own:

console.log("...")      // console is an object; log is one of its methods
Math.PI                 // Math is an object; PI is one of its properties
document.getElementById  // the whole web page is an object called document
Big Idea
In JavaScript, almost everything that is not a primitive (string, number, boolean, null, undefined, bigint, symbol) is an object. Arrays are objects. Functions are objects. Dates are objects.

// The Vocabulary

const car = {
  make: "Toyota",          // a PROPERTY: key "make", value "Toyota"
  year: 2021,              // another property
  honk() {                 // a METHOD: a property whose value is a function
    return "Beep!";
  }
};
KeyThe name of a detail (make)
ValueWhat is stored under that name ("Toyota")
PropertyA key and its value together
MethodA property that holds a function: something the object can do

// Think of It Like a Form

An object is like a filled-in form. The labels on the form are the keys ("Name:", "Year:"). What is written in each box is the value. Methods are the instructions printed at the bottom ("To honk, press here").

// The Road Ahead

Lesson Question it answers
Object IntroHow do I create one?
Object PropertiesHow do I read, add, change, and remove details?
Object MethodsHow do I give an object actions?
Object thisHow does a method refer to its own object?
Object DisplayHow do I show an object's contents?
Object ConstructorsHow do I make many objects of the same shape?

Further down the road

Objects go much deeper than this section. So the names are familiar when you meet them later, the advanced path covers:

// Quick Check

In const car = { make: "Toyota", honk() { return "Beep!"; } };, what is honk?

  1. A key
  2. A value
  3. A method
  4. A primitive
Show answer
C. A method is a property whose value is a function: something the object can do. make is a key, and "Toyota" is its value.

Which of these is not an object?

  1. An array
  2. A date
  3. The number 42
  4. A function
Show answer
C. Numbers are primitives. Arrays, dates, and even functions are all objects in JavaScript.

Why use one object instead of separate variables like studentName, studentGrade?

  1. Objects run faster
  2. The details travel together as one thing you can pass, store, or list
  3. Variables cannot hold strings
  4. Objects cannot be changed
Show answer
B. Bundling related details lets you pass a whole student to a function or keep thirty students in one list.

// Try It

  1. Pick something around you (a phone, a book, a pet) and list five details about it
  2. Click Open Playground and write those details as an object
  3. Print one of its values using a dot, like book.title
  4. Log Math.PI, then log Math.round(4.6). Which one is a property and which is a method?
// Video Walkthroughs
Last updated: Oct 10, 2026, 12:52 AM ET