Essential JavaScript

Intro to Objects

We are going to learn how to work with objects, but first want to show you a quick example:

const person = {
  firstName: 'John',
  lastName: 'Doe',
  age: 22,
};

Above, we see a variable person that contains an object.

Objects are a way to group related pieces of information into a single place so they are easier to work with.

Until now, we could have three separate variables to represent the object above:

const firstName = 'John';
const lastName = 'Doe';
const age = 22;

Now we can encapsulate those values into an object and store it in a single variable.


Learning Goals

Code Editor