Ajax-loader-large-white
Introduction to Objects II
An Objective Review

Let's review the basics of objects covered in our previous lesson on objects. Recall we can create objects using either literal notation or constructor notation.

  • Literal notation creates a single object. Literal notation uses curly brackets { } and the object's default properties are defined within the brackets using property:value notation.
  • Constructor notation involves defining an object constructor. And like defining a function, we use the function keyword. You can think of this constructor as a "template" from which you can create multiple objects. To create a new object from a constructor, we use the new keyword.
Instructions

Finish the james object by adding properties to it. His job should be "programmer" and should have a married property set to false.

Create a new gabby object using the Person constructor. She should have a job of "student" and her married property should be true.

?
Stuck? Get a hint! Hint
Get live, fast support from Codecademy Advisors when you get stuck. Learn more.

Take a look at these objects created using literal and constructor notation:

var obj = {
property: "value",
otherProp: 42
};
var obj = new Object("value", 42);

Remember properties of objects created with literal notation should be separated by commas.

For other reminders about how objects work, revisit the first course on objects.

script.js

Learn more advanced JavaScript in our new AngularJS course!

  Delete