es6-destructuring Flashcards
1
Q
What is destructuring, conceptually?
A
unpacking values from arrays, or properties from objects into variables
2
Q
What is the syntax for Object destructuring?
A
let {
propertyname: variablename
}=objectname
before the colon is the property of the object and after the colon is the variable
3
Q
What is the syntax for Array destructuring?
A
let num = [1,2,3,4]
let [a,b,c,d]=num
a=1, b=2, c=3, d=4
4
Q
How can you tell the difference between destructuring and creating Object/Array literals?
A
the object/array variable name is declared after the object/array literal for destructuring; let object/array literal = variableName instead of let variableName=object/array literal