Let's say I have an array of arrays, like so:
var arrs = [
[1, "foo", "bar", "baz"],
[2, "bar", "baz", "qux"],
[3, "baz", "qux", "thud"]
];
I want to use ES6's destructuring assignment to get the first element of each array as an individual variable, and repack the rest of the elements as another array. In pseudocode:
for (let [first, *rest] of arrs) { // What is the proper way to do *rest?
console.log(first); // Should be a number
console.log(rest); // Should be an array of strings
}
Is something like this possible?
That's what
...
does: