110
rated 0 times
[
112]
[
2]
/ answers: 1 / hits: 21915
/ 7 Years ago, mon, october 16, 2017, 12:00:00
Can I avoid declaring a useless variable when array destructuring when I am only interested in array values beyond index 0?
In the following, I want to avoid declaring a
, I am only interested in index 1 and beyond.
// How can I avoid declaring a?
const [a, b, ...rest] = [1, 2, 3, 4, 5];
console.log(a, b, rest);
More From » arrays