Properties
File Location
We will be working in the following file:
In the pre-work, you learned about how to create an object and assign it properties. This is just a review.
An object with no properties
Object Literal with two properties
Look at the code below.
Use . to access the properties.
Nested properties
You also saw in the left had side module how objects can be nested. Arrays can also nested inside objects.
We could loop over the episode info array like this
Challenges
Create an object with several properties. Print each to the console.
Add an array as a property and loop over its elements. Print them to the console.
Recall that objects can be created from a model. Create a model asking for a person's age, height, eye color, hair color, and whether or not they wear glasses (make this a boolean value). Then create yourself as an object with that model.
Last updated