JavaScript allows us to extract elements of an array into an object using destructuring. The reason for this is due to JavaScript treating arrays as objects. With the exsception of primitives, everything in JavaScript is an object.

Example

const exArray = ["Chocolate", 1.99, "bar"];

const {1: price, 2: itemType} = exArray;

console.log(price); //1.99
console.log(itemType); //bar