destructuring Flashcards
1
Q
Destruction
const obj = {first: ‘adam’, last: ‘cadieux’, age: 45};
instead:
const f = obj.fisrt; const l = obg.last;
A
const {first:f, last l} obj:
2
Q
Destruction
const obj = {first: ‘adam’, last: ‘cadieux’, age: 45};
instead:
const f = obj.fisrt; const l = obg.last;
A
const {first:f, last l} =obj:
or even
const {first:, last } =obj:
3
Q
Destruction Array
const arr = [‘a’,’b’];
const x =arr[0]; const y =arr[1];
A
const [x,y] = arr;