Hint
... is context-dependent: "rest" when collecting into an array (parameter or destructuring), "spread" when expanding an array into individual values.
function fn(first, ...rest) {
console.log(first);
console.log(rest);
}
const arr = [1, 2, 3, 4, 5];
fn(...arr);
const [a, b, ...remaining] = arr;
console.log(a);
console.log(b);
console.log(remaining);1 [2, 3, 4, 5] 1 2 [3, 4, 5]
Explanation: fn(...arr) expands arr as individual args: first=1, rest=[2,3,4,5]. Array destructuring: a=1, b=2, remaining=[3,4,5]. Same syntax ... means rest in param position, spread in expression position.
Key Insight: ... is context-dependent: "rest" when collecting into an array (parameter or destructuring), "spread" when expanding an array into individual values.