Practical immutability, not empty theory
Spread and rest help you create new structures instead of modifying the old ones.
In reactive interfaces, mutating original state often creates behavior that is difficult to trace. Controlled copies make changes more predictable.
A useful rule is simple: if a value is shared by several parts of the system, avoid mutating it directly.
Spread in arrays
Copy or merge lists without touching the source.
- `const copy = [...original]`
- `const all = [...a, ...b]`
Spread in objects
Create new objects with explicit overrides.
- `const copy = { ...obj }`
- `const updated = { ...obj, active: true }`
Rest in functions
Group variable arguments into one real array.
- `function sum(...nums) {}`
- Useful in flexible helpers