Вы деструктурируете объекты следующим образом:
const {
key: yourVar = 'defaultVal'
} = obj
Массивы похожи, но вместо ссылки на ключи вы ссылаетесь на сами элементы:
const [
firstElem,
secondElem
] = arr
const obj = {
a: 1,
b: {
b1: 'a'
}
};
const objWithArr = {
a: 1,
b: [{
key: 5,
}, {
key: 6
}]
}
const {
b: {
b1: b1Val = 'default',
} = {},
} = obj;
const {
b: [{
key: firstKey,
} = {},
{
key: secondKey,
} = {}
] = [],
} = objWithArr;
console.log(b1Val);
console.log(firstKey);
console.log(secondKey);