en.javascript.info/1-js/4-more-syntax/2-destructuring-assignment/1-destructuring-assignment/task.md
Ilya Kantor 3f5f2cac8b work
2016-07-22 20:47:41 +03:00

33 lines
538 B
Markdown

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