---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# WeakSet

The **`WeakSet`** constructor lets you create
`WeakSet` objects that store weakly held _objects_ in a collection.

## Syntax

```js
new WeakSet()
new WeakSet(iterable)
```

> **Note:** `WeakSet()` can only be constructed with `new`. Attempting to call it without `new` throws a [`TypeError`](../../globals/TypeError/TypeError.mdx).

### Parameters

- `iterable` _**optional**_
  - : If an [iterable object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/for...of) is passed, all of its elements will be added to the new
    `WeakSet`. null is treated as undefined.
