ES6 Destructuring & Template Literals Flashcards

1
Q

What is destructuring, conceptually?

A

Taking the values within the object and assign it to a variable

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, index 2] = array

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: variable name goes on the right of the assign operator ( let/const { } or [ ] = variable )
Creating: variable name goes on the left of the assign operator ( variable = { } or [ ])

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

What is the syntax for writing a template literal?

A

Template literals use backticks rather than single or double quotes and the javascript expression is as follows: ${variable}

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

What is “string interpolation”?

A

A process where variables and expressions is embedded in a string. The variable/expression has to be placed in a space block as follows:
${variable_name}

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