From the course: JavaScript Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Accessing object properties

Accessing object properties - JavaScript Tutorial

From the course: JavaScript Essential Training

Start my 1-month free trial

Accessing object properties

- [Instructor] Accessing an entire object is useful in some cases, but in other cases you need access to individual properties and methods within that object. There are two ways of accessing object properties, dot notation and bracket notation. Let's look at dot notation first. I want to output the value of just the pocket number property. To do that, I'll first console logout, the pocketNum value:, then I'll use dot notation by first accessing the backpack object, then adding a dot, and then adding the property I want, in this case pocket number. And you can see when I add the dot, VS Code automatically says, "Hey I see you're using dot notation. What is it you want?" And it suggests to me pocket number. Save, check it in the console, and you see now we have the full object, and then we have just a pocket number value. Dot notation is called dot notation because you literally use a dot to separate the…

Contents