es6-destructuring Flashcards

1
Q

What is destructuring, conceptually?

A

Destructuring is taking apart the structure of something, removing the order or frame that it exists inside and dealing with the inner workings

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

There is a longhand destructure if you want to give variables new names: {obj-prop1: new-name1} = obj and a shorthand if you want to give the variables the same names of the object properties: {obj-prop1} = obj

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

[el1, el2, el3] = [1, 2, 3], if there are more elements in the array being assigned then they will be discarded, if there are less elements then the variables on the left being assigned values will be undefined if not given an element

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