Hint
Expand iterable into individual elements — arrays, function args, object spreading
// 1. Spread in function calls — expand array as arguments
const nums = [1, 5, 3, 2, 4];
Math.max(...nums); // 5 — same as Math.max(1,5,3,2,4)
// 2. Copy and combine arrays (immutable operations)
const a = [1, 2, 3];
const b = [4, 5, 6];
const copy = [...a]; // [1,2,3] — shallow copy
const merged = [...a, ...b]; // [1,2,3,4,5,6]
const prepend = [0, ...a]; // [0,1,2,3]
// 3. Spread in object literals (ES2018)
const base = { a: 1, b: 2 };
const extended = { ...base, c: 3 }; // { a:1, b:2, c:3 }
const override = { ...base, b: 99 }; // { a:1, b:99 } — later wins
// 4. Convert iterable to array
const set = new Set([1,2,3]);
[...set]; // [1,2,3]
[...'hello']; // ['h','e','l','l','o']
[...document.querySelectorAll('p')]; // NodeList → Array
// 5. Clone + update (immutable pattern)
const state = { user: 'Alice', count: 0 };
const newState = { ...state, count: state.count + 1 };