1 min read

Destructuring

Destructuring is a new syntax that allows you to extract values from arrays and objects into variables.

Array Destructuring

const numbers = [1, 2, 3];
const [a, b, c] = numbers;
console.log(a, b, c); // 1 2 3

Object Destructuring

const person = { name: 'John', age: 30 };
const { name, age } = person;
console.log(name, age); // "John" 30