Locked lesson.
About this lesson
What are objects, and how does JavaScript use them?
Exercise files
Download this lesson’s related exercise files.
Objects.docx58.8 KB Objects - Solution.docx
59 KB
Quick reference
Objects
Objects are similar to arrays but use name/value pairs instead of index numbers.
When to use
Use objects whenever you have more complex data to store, or when simple index numbers won't do the trick.
Instructions
Objects are similar to arrays but use name/value pairs instead of index numbers.
An object looks like this:
var customer = {
firstName: "John",
lastName: "Elder"
}
You call an object item like this:
customer.firstName;
or...
customer["firstName"];
Hints & tips
- Objects are similar to arrays
- Objects use name/value pairs instead of index numbers
- Objects use curly brackets instead of straight ones
Lesson notes are only available for subscribers.