JavaScript: objects

An object groups related data under named properties, making a value easier to describe and use.

What you will learn

Minimal example

const user = { name: 'Mina', age: 20 };
console.log(user.name); // "Mina"
user['age'] = 21;
user.active = true;

Use dot notation for a known property name. Use bracket notation when the property name is stored in a variable or contains characters that dot notation cannot express.

Common mistakes