destructuring - mmedrano9438/peripheral-brain GitHub Wiki

The destructuring assignment syntax is a JavaScript expression that makes it possible to unpack values from arrays, or properties from objects, into distinct variables.

let a, b, rest; [a, b] = [10, 20];

console.log(a); // Expected output: 10

console.log(b); // Expected output: 20

[a, b, ...rest] = [10, 20, 30, 40, 50];

console.log(rest); // Expected output: Array [30, 40, 50]