Destructuring
Destructuring lets you pull values out of arrays and objects quickly, without writing multiple lines of code. Think of it like unpacking a suitcase: instead of taking out each item one by one, you unpack everything at once.
// Object destructuring
const user = { name: "Daniel", age: 20, city: "Dallas" }
const { name, age } = user
console.log(name) // "Daniel"
// Array destructuring
const colors = ["red", "green", "blue"]
const [first, second] = colors
console.log(first) // "red"
// With default values
const { role = "user" } = user
console.log(role) // "user" (default since not in object)