LOGBOOK

HELP

Quiz Entry - updated: 2026.06.20

How do you read and change the properties of a JavaScript object?

You read and write properties with dot notation (object.property), or with bracket notation (object['property']) when the name is dynamic.

Once an object exists, the dot operator lets you reach inside it. Put the property name after a dot to read it, or assign to it to change it:

let person = {
    firstName: 'Hans',
    name: 'Meier',
    age: 22
};

console.log(person.name);  // 'Meier'  — reading
console.log(person.age);   // 22

person.age = 34;           // writing — change an existing property

There's a second, equivalent way: bracket notation, where the property name is a string inside [ ]:

person['name']        // 'Meier'
person['age'] = 35;   // change it

When should you use brackets instead of the dot? When the property name lives in a variable (person[fieldName]) or contains characters the dot can't handle, like spaces or hyphens (person['home address']). For ordinary fixed names, dot notation is shorter and clearer, so it's the default choice.

From Quiz: WEBT / Introduction to JavaScript | Updated: Jun 20, 2026