JavaScript › Destructuring, Spread & Rest
What does the spread operator (...) do when used on an array?
BeginnerAnswer
Spread expands an iterable's elements in place, commonly used to copy an array or merge multiple arrays into a new one without mutating the originals.
const a = [1, 2];
const b = [3, 4];
const combined = [...a, ...b]; // [1, 2, 3, 4]Real-world example Merging a default list of settings with user-provided overrides.