es6-destruturing Flashcards

1
Q

What is destructuring, conceptually?

A

Assigns properties of an object (or values of an array) to individual 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 { property1: variable1, property2: variable2 } = objectName;
let/const, opening curly brace, property name. Colon, variable name, comma, repeat for any other properties, closing curly brace, equal sign, object’s name, semicolon

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 [x, y, z] = array;
let/const, opening brackets, name of variable separated by commas, closing bracket, equal sign, name of array, semicolon

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

Destructuring: the object/array name goes on the right of the assignment operator, braces/brackets are on the left side of the assignment operator
Creating: the variable name goes on the left of the assignment operator, braces/brackets are on the right side of the assignment operator

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