es6-destructuring Flashcards
What is destructuring, conceptually?
Destructuring is taking apart the structure of something, removing the order or frame that it exists inside and dealing with the inner workings
What is the syntax for Object destructuring?
There is a longhand destructure if you want to give variables new names: {obj-prop1: new-name1} = obj and a shorthand if you want to give the variables the same names of the object properties: {obj-prop1} = obj
What is the syntax for Array destructuring?
[el1, el2, el3] = [1, 2, 3], if there are more elements in the array being assigned then they will be discarded, if there are less elements then the variables on the left being assigned values will be undefined if not given an element