StackOverflow - StackOverflow

Array Destructuring Skipping Values

You could treat the array as object and destructure with the index as key and assign to a new variable name.

const
    array = [37, 38, 39, 40, 41, 42, 43],
    { 5: result } = array;

console.log(result);

Was this helpful?

Have a different question?

Can't find the answer you're looking for? Submit your own question to our community.

🛎️ Get Weekly OTA Fixes

New answers, vendor issues, and updates — straight to your inbox.