Array destructuring
The simplest form of destructuring is array destructuring assignment:
let input = [1, 2];
let [first, second] = input;
console.log(first); // outputs 1
console.log(second); // outputs 2
This creates two new variables named first and second. This is equivalent to using indexing, but is much more convenient:
first = input[0];
second = input[1];
Destructuring works with already-declared variables as well:
// swap variables
[first, second] = [second, first];
And with paramete