Skip to content

Commit 4b5ae3a

Browse files
committed
added last part of my initial learning
1 parent 1b8b2c7 commit 4b5ae3a

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,26 @@ Destructing is a new way to extract values from objects and arrays. We can use t
591591

592592
```javascript
593593
// Consider this object
594-
const person = {
595-
594+
var person = {
595+
name: "Anurag",
596+
age: 20,
597+
address: {
598+
city: "Hyderabad",
599+
state: "Telangana",
600+
country: "India"
601+
}
596602
}
603+
604+
// We can extract the values like this
605+
var { name, age } = person;
606+
console.log(name, age); // Anurag 20
607+
```
608+
609+
This concept can also be used for arrays.
610+
611+
```javascript
612+
var arr = [1, 2, 3, 4, 5];
613+
614+
var [a, b, c, d, e] = arr;
615+
console.log(a, b, c, d, e); // 1 2 3 4 5
597616
```

0 commit comments

Comments
 (0)