javascript / beginner
Snippet
Accessing Object Properties
You can use dot notation to access specific values stored inside an object by their key name.
snippet.js
1
2
const car = { brand: 'Toyota', year: 2022 };console.log(car.brand);
nodejs
Breakdown
1
const car = { brand: 'Toyota', year: 2022 };
Defines an object with two properties: brand and year.
2
console.log(car.brand);
Uses the dot operator to retrieve and print the value associated with the key 'brand'.