A Pen by Afaq Ahmed Khan on CodePen.
Created
November 17, 2018 12:35
-
-
Save afaqahmedkhan/be136e4669eb503e72a408ef3b9b3a3a to your computer and use it in GitHub Desktop.
Object Oriented Programming: Use Dot Notation to Access the Properties of an Object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let dog = { | |
name: "Spot", | |
numLegs: 4 | |
}; | |
// Add your code below this line | |
console.log(dog.name); | |
console.log(dog.numLegs); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The last challenge created an object with various properties, now you'll see how to access the values of those properties. Here's an example:
Dot notation is used on the object name, duck, followed by the name of the property, name, to access the value of "Aflac".
Print both properties of the dog object below to your console.