es6-destructuring Flashcards
1
Q
What is destructuring, conceptually?
A
an alternative way to assign values of properties to variables
2
Q
What is the syntax for Object destructuring?
A
let {propertyName1: variable1, propertyName2: variable2} = object
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
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.