ES6 Destructuring & Template Literals Flashcards
What is destructuring, conceptually?
Taking the values within the object and assign it to a variable
What is the syntax for Object destructuring?
let {
property1: variable1,
property2: variable2
} = object;
What is the syntax for Array destructuring?
let [index1, index 2] = array
How can you tell the difference between destructuring and creating Object/Array literals?
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 [ ])
What is the syntax for writing a template literal?
Template literals use backticks
rather than single or double quotes and the javascript expression is as follows: ${variable}
What is “string interpolation”?
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}