es6-destructuring Flashcards

1
Q

What is destructuring, conceptually?

A

an alternative way to assign values of properties to variables

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 {propertyName1: variable1, propertyName2: 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

const arr = [1,2,3]
let [x, y, z] = arr;
you can use commas to skip indexes
let [x,,z] == arr

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

if you’re creating curly braces are on the right, if you’re destructing they’re on the left.

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