---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# WeakMap.prototype.set

The **`set()`** method adds a new element with a specified key
and value to a `WeakMap` object.

## Syntax

```js
set(key, value)
```

### Parameters

- `key`
  - : Required. Must be `object`. The key of the element to add to the
    `WeakMap` object.
- `value`
  - : Required. Any value. The value of the element to add to the `WeakMap`
    object.

### Return value

The `WeakMap` object.
