---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# Map.prototype.set()

The **`set()`** method adds or updates an entry in a `Map` object with a specified key and a value.

## Syntax

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

### Parameters

- `key`
  - : The key of the element to add to the `Map` object. The key may be any [JavaScript type](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures) (any [primitive value](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#primitive_values) or any type of [JavaScript object](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#objects)).
- `value`
  - : The value of the element to add to the `Map` object. The value may be any [JavaScript type](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures) (any [primitive value](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#primitive_values) or any type of [JavaScript object](https://developer.mozilla.org/docs/Web/JavaScript/Data_structures#objects)).

### Return value

The `Map` object.
