> For the complete documentation index, see [llms.txt](https://strctr.gitbook.io/programming/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://strctr.gitbook.io/programming/01-languages/javascript/01-language/b-structured/b3-destructing/06-destructing-collections.md).

# 06. Destructing collections

Деструктурируя `Map` или `Set` используй синтаксис для деструкции массива (поскольку объекты этих классов iterable):

```javascript
const m = new Map();
m.set("a", 1);
m.set("b", 2);

const [p1, p2] = m;
p1;
// (2) ["a", 1]
p2;
// (2) ["b", 2]

let [x, y] = new Set(["a", "b"]); // x='a'; y='b’;
```
