let [, secondPerson, , fourthPerson] = name // first and third person is omitted
let [, secondPerson, , fourthPerson] = names // first and third person is omitted
console.log(secondPerson, fourthPerson)
```
@ -218,7 +218,7 @@ console.log(w, h, a, p)
20 10 200 undefined
```
If the key is not found in the object the variable will be assigned to undefined. In case, the key is not in the object we can give a default value during declaration. See the example.
If the key is not found in the object the variable will be assigned to undefined. In the case that the key is not in the object, we can give a default value during declaration. See the example.
// Lets create a function which give information about the person object without destructuring
// Let's create a function which give information about the person object without destructuring
const getPersonInfo = obj => {
const skills = obj.skills
@ -300,6 +300,9 @@ const getPersonInfo = obj => {
}
console.log(getPersonInfo(person))
/*
Asabeneh Yetayeh lives in Finland. He is 250 years old. He is an Instructor and Developer. He teaches HTML, CSS, JavaScript, React, Redux, Node, MongoDB, Python and D3.js. He speaks Amharic, English and a little bit of Suomi(Finnish).
*/
```
### Object parameter with destructuring
@ -335,7 +338,7 @@ const getPersonInfo = ({
}
console.log(getPersonInfo(person))
/*
Asabeneh Yetayeh lives in Finland. He is 200 years old. He is an Instructor and Developer. He teaches HTML, CSS, JavaScript, React, Redux, Node, MongoDB, Python and D3.js. He speaks Amharic, English and a little bit of Suomi(Finnish)
Asabeneh Yetayeh lives in Finland. He is 250 years old. He is an Instructor and Developer. He teaches HTML, CSS, JavaScript, React, Redux, Node, MongoDB, Python and D3.js. He speaks Amharic, English and a little bit of Suomi(Finnish).
*/
```
@ -373,7 +376,7 @@ Assess Test Result 4/1/2020 1:00 false
### Spread or Rest Operator
When we destructure an array we use the spread operator(...) to get the rest elements as array. In addition to that we use spread operator to spread arr elements to another array.
When we destructure an array we use the spread operator(...) to get the rest elements as array. In addition to that we use spread operator to spread array elements to another array.
### Spread operator to get the rest of array elements