Lesson 18 / 38
Spread & Rest with Objects
Copying, merging, and picking properties without mutation.
Spreading objects
... copies an object's own properties into a new one — great for immutable updates.
const user = { name: "Ada", age: 36 };
const updated = { ...user, age: 37 };
console.log(updated); // { name: 'Ada', age: 37 }Rest in destructuring
Pull specific keys out and gather everything else into a new object.
const { name, ...rest } = { name: "Ada", age: 36, city: "London" };
console.log(name); // Ada
console.log(rest); // { age: 36, city: 'London' }Shallow copy only
Spread makes a shallow copy — nested objects inside are still shared by reference.