JavaScript theorytheory 0/50 · 0%
Data · easy

5. Objects

Property access, shorthand, spread and destructuring.

Objects map string (or symbol) keys to values. Dot access is for known names, bracket access for dynamic ones. Spread copies own enumerable properties one level deep.

const tx = { to: "0xabc", value: 1n };
const { to, value } = tx;
const next = { ...tx, value: 2n };
tx["to"];

Spread is a shallow copy: nested objects are still shared references.

Check your understanding

  1. 1. What does `{ ...tx }` produce?

  2. 2. When do you need bracket access?

  3. 3. What does destructuring do?