Code highlights logo

Learn

Objects

Accessing Properties

One way to access properties of an object is by using the dot notation. The dot notation is straightforward and concise, making it widely used in JavaScript.

Here is an example:

1const person = {
2 name: 'John Doe',
3 age: 30,
4 occupation: 'Web Developer'
5};
6
7console.log(person.name); // Output: John Doe
8console.log(person.age); // Output: 30
9console.log(person.occupation); // Output: Web Developer

In the example above, we have an object called person with three properties: name, age, and occupation. We can access these properties using dot notation by appending the property name to the object name.


Instructions

1.

Print the value of the property name from the person object using dot notation.

Sign up to start coding

Already have an account?

Sign In

Course content