# Spread & Rest with Objects — JavaScript

Source: https://www.geekswithgeeks.com/en/javascript/js-object-spread-rest

> Copying, merging, and picking properties without mutation.

## Spreading objects

`...` copies an object's own properties into a new one — great for immutable updates.

```js
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.

```js
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.
