538 B
538 B
importance: 5
Destructuring assignment
We have an object:
let user = {
name: "John",
years: 30
};
Write the destructuring assignment that reads:
name
property into the variablename
.years
property into the variableage
.isAdmin
property into the variableisAdmin
(false if absent)
The values after the assignment should be:
let user = { name: "John", years: 30 };
// your code to the left side:
// ... = user
alert( name ); // John
alert( age ); // 30
alert( isAdmin ); // false