Chapter VII · Objects

Properties

Properties are key-value pairs stored inside an object representing its attributes or data state.

01 How It Works

Think of labeled storage slots inside a filing cabinet drawer.

Keys map to values of any valid data type using dot or bracket notation.

example.js
const car = { brand: "Toyota", year: 2023 };
console.log(car.brand);
  1. 1. Target the host object.

  2. 2. Specify the property key identifier.

  3. 3. Retrieve or update its associated value.

02 Practical Example

Here is how you might see this concept applied in real-world code:

practical.js
const user = { role: "admin" };
user.active = true; // Adding property

Key Takeaway

Properties hold the state data inside objects.

Related Concepts