Lesson content
Read, practise, then check your understanding
Destructuring extracts array positions or object properties. Defaults run only for undefined. Rest collects remaining values; spread expands iterables or own enumerable properties.
Clear data movement
const user = { id: 7, name: "Mira", role: "editor" };
const { id, name, role = "viewer", ...metadata } = user;
const first = [1, 2, 3];
const combined = [...first, 4, 5];
Object spread is shallow and later properties overwrite earlier ones. It does not copy the prototype or faithfully clone descriptors. Rename bindings with { name: displayName }; swap values with array destructuring. Avoid overly deep patterns that hide validation or make missing data hard to diagnose.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.