🍳 Destructuring
Use destructuring to work with objects with ease.
What is the name of the variable declared below?
const { foo: bar } = { foo: 23 }
Destructuring Examples
// Object destructuring
const person = {
name: 'John',
age: 32,
city: 'New York',
country: 'USA'
};
const { name, age } = person;
// Object destructuring with alias
const { name: firstName, age: years } = person;
// Array destructuring
const fruits = ['apple', 'banana', 'orange'];
const [first, second, third] = fruits;