What is this code doing?
const friends = ['Aliyah', 'Alex', 'Ben', 'Cassidy', 'Carlos'] const { length, 0: first, [length - 1]: last } = friends
const friends = ['Aliyah', 'Alex', 'Ben', 'Cassidy', 'Carlos'] const { length, 0: first, [length - 1]: last } = friends console.log(first) // Aliyah console.log(last) // Carlos
Since arrays are just objects with numeric keys and a length property, we can use destructuring and computed property names in order to grab the first and last elements in any array. Kind of worthless, but kind of cool.