# JavaScript Objects, Destructuring and Spread

Work with objects and modern syntax.

```js
const user = { name: "Ann", age: 30, address: { city: "Oslo" } };
const { name, age = 18 } = user;             // destructuring with default
const { address: { city } } = user;           // nested
const [first, , third] = [1, 2, 3];
const copy = { ...user, age: 31 };            // shallow copy and override
const merged = Object.assign({}, a, b);
Object.keys(user); Object.values(user); Object.entries(user);
Object.fromEntries([["a", 1]]);
user?.address?.zip;                           // optional chaining
user.nick ?? "none";                          // nullish coalescing (only null/undefined)
user.nick || "none";                          // any falsy value
function f(a, b = 2, ...rest) {}              // default and rest params
structuredClone(user);                        // deep copy
```
