|
|
|
@ -57,7 +57,7 @@ Destructuring is a way to unpack arrays, and objects and assigning to a distinct
|
|
|
|
|
|
|
|
|
|
```js
|
|
|
|
|
const names = ['Asabeneh', 'Brook', 'David', 'John']
|
|
|
|
|
let [firstPerson, secondPerson, thirdPerson, fourth Person] = names
|
|
|
|
|
let [firstPerson, secondPerson, thirdPerson, fourthPerson] = names
|
|
|
|
|
|
|
|
|
|
console.log(firstName, secondPerson,thirdPerson, fourthPerson)
|
|
|
|
|
```
|
|
|
|
@ -209,7 +209,7 @@ const rectangle = {
|
|
|
|
|
height: 10,
|
|
|
|
|
area: 200
|
|
|
|
|
}
|
|
|
|
|
let { width: w, heigh: h, area: a, perimeter: p } = rectangle
|
|
|
|
|
let { width: w, height: h, area: a, perimeter: p } = rectangle
|
|
|
|
|
|
|
|
|
|
console.log(w, h, a, p)
|
|
|
|
|
```
|
|
|
|
@ -226,7 +226,7 @@ const rectangle = {
|
|
|
|
|
height: 10,
|
|
|
|
|
area: 200
|
|
|
|
|
}
|
|
|
|
|
let { width, heigh, area, perimeter = 60 } = rectangle
|
|
|
|
|
let { width, height, area, perimeter = 60 } = rectangle
|
|
|
|
|
|
|
|
|
|
console.log(width, height, area, perimeter) //20 10 200 60
|
|
|
|
|
//Lets modify the object:width to 30 and perimeter to 80
|
|
|
|
@ -239,7 +239,7 @@ const rectangle = {
|
|
|
|
|
area: 200,
|
|
|
|
|
perimeter: 80
|
|
|
|
|
}
|
|
|
|
|
let { width, heigh, area, perimeter = 60 } = rectangle
|
|
|
|
|
let { width, height, area, perimeter = 60 } = rectangle
|
|
|
|
|
console.log(width, height, area, perimeter) //20 10 200 80
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|