How to assign array elements to multiple variables in one go?
let arr = ["one", "two", "three", "four"];
let [first, second, ...rest] = arr;
// first: "one"
// second: "two":
// rest: [ "three", "four" ]
How to assign object properties to multiple variables in one go?
let obj = {
firstName: "Alice",
lastName: "Jones",
birthYear: "1995",
profession: "IT"
};
// variable names must match property names:
let { firstName, lastName, ...objRest } = obj;
// firstName: "Alice"
// lastName: "Jones"
// objRest: { birthYear: '1995', profession: 'IT' }