How can I ignore certain returned values from array destructuring? How can I ignore certain returned values from array destructuring? arrays arrays

How can I ignore certain returned values from array destructuring?


Can I avoid declaring a useless variable when array destructuring when I am only interested in array values beyond index 0?

Yes, if you leave the first index of your assignment empty, nothing will be assigned. This behavior is explained here.

// The first value in array will not be assignedconst [, b, ...rest] = [1, 2, 3, 4, 5];console.log(b, rest);