次のような配列の配列があるとしましょう。
var arrs = [
[1, "foo", "bar", "baz"],
[2, "bar", "baz", "qux"],
[3, "baz", "qux", "thud"]
];
ES6 の分割割り当てを使用して、各配列の最初の要素を個別の変数として取得し、残りの要素を別の配列として再パックしたいと考えています。擬似コード:
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
}
このようなことは可能ですか?