ES6 array destructuring for specific index [duplicate]

I have an Array const arr = new Array(100).

And I set

arr[0] = 'A'
arr[49] = 'X'

When destructuring the 1st element, I can do it like:

let [first] = arr

How the statement would be like if I want to access to the 50th element by destructuring expression?


You can grab the element using object destructuring, like so:

const arr = Array(50).fill(0).map((_, i) => `Element ${i + 1}`)

const {49: fifty} = arr
console.log(fifty)