javascript class destructor code example
Example 1: javascript object destructuring
let obj = {name: 'Max', age: 22, address: 'Delhi'};
const {name, age} = obj;
console.log(name);
console.log(age);
console.log(address);
let a, b, rest;
[a, b] = [10, 20];
console.log(a);
console.log(b);
[a, b, ...rest] = [10, 20, 30, 40, 50];
console.log(rest);
Example 2: javascript function destructuring
function f() {
return [1, 2];
}
let a, b;
[a, b] = f();
console.log(a);
console.log(b);
Example 3: object destructuring
const user = {
name: "Jenny",
age: "12",
hobbies: ["Sport", "Programmieren", "essen"],
};
const { age } = user;
console.log(age);
Example 4: js object destructuring
const { [propName]: identifier } = expression;