es6-destructuring Flashcards

1
Q

What is destructuring, conceptually?

A

Assigning properties of an object or indexes of an array to variables in one line

or

Allows the creation of variables from properties of objects or indexes of arrays

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the syntax for Object destructuring?

A

let { property1: variable1, property2: variable2 } = object;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the syntax for Array destructuring?

A

let [index1, index2, index3] = nameOfArray;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How can you tell the difference between destructuring and creating Object/Array literals?

A

In de-structuring objects or arrays, the name of the object or array is on the right side of the assignment operator; and to the left of the assignment operator for an object de-structuring, the property or index name is on the left side of the colon and the variable name is on the right side of the colon.
For array de-structuring, the indexes are listed within brackets ( [ ] ).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly