A guide to destructuring in JavaScript – Piccalilli

October 9, 2024

A destructuring assignment allows you to extract individual values from an array or object and assign them to a set of identifiers without needing to access the values of each element the old-fashioned way—one at a time, by index or key like this:


const myArray = [ true, false, false ];
const firstElement = myArray[0];
const secondElement = myArray[1];
const thirdElement = myArray[2];

Source: A guide to destructuring in JavaScript – Piccalilli

A nice succinct overview of destructuring in JavaScript