Objects and properties
Objects and properties
Objects store key-value properties. Access properties with dot or bracket notation. Destructuring extracts values into variables; optional chaining safely accesses nested values that may be missing.
Try it yourself
Change the example, run it, and explain the result in your own words. Then create one variation of your own.
Key idea
Use the example as a starting point, not something to memorize. Practise, inspect the result and make small improvements.
Code example
const user = { name: "Mina", role: "student" };
const { name, role } = user;
console.log(`${name}: ${role}`);