What is Destructuring?
Destructuring, or destructuring assignment, is a JavaScript feature that makes it
easier to extract data from arrays and objects
For example...
An MDN document on Destructing Assignment can be found
Here
It is worth taking a look to remind you of what can be done
under the heading 'Destructuring'.
This document demonstrates something else I had not yet come across.
You can create a variable which, when assigning a value, is preceeded by three
dots (...), eg ...rest or ...c
which then creates a variable array with all the remaining values.
By this I mean, eg:
let a, b, rest;
//now to assign values to a & b only
[a, b] = [10, 25];
console.log(a);
// expected output: 10
console.log(b); // expected output: 20
// BUT if you assign values like this
[a, b, ...rest] = [10, 20, 30, 40, 50, 60];
// Then a will = 10
// b will = 20
// rest will be an array = "[30, 40, 50, 60]"
// Note it is NOT referred to as ...rest
console.log(rest);
// expected output: 30, 40, 50, 60