#4 - Destructuring
The destructuring syntax allows you to extract an array’s elements or an object’s properties into distinct variables. This syntax is commonly used in real world applications where only a subset of values or properties is needed. One important keyword related to destructuring is the rest keyword. Check out the example below to understand the rest keyword in restructuring.
xxxxxxxxxx
const arr = [1,2,3,4,5,6,7,8,9,10];
const [a,b,c,rest] = arr;
console.log(a); //1
console.log(b); //2
console.log(c); //3
console.log(rest); //[4,5,6,7,8,9,10]
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment