Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The set() method of WeakMap instances adds a new entry with a specified key and value to this WeakMap, or updates an existing entry if the key already exists.
The key of the entry to add to or modify within the WeakMap object. Must be either an object or a non-registered symbol. Object keys are compared by reference, not by value.
valueThe value of the entry to add to or modify within the WeakMap object. Can be any value.
The WeakMap object.
Thrown if key is not an object or a non-registered symbol.
| ECMAScript® 2027 Language Specification # sec-weakmap.prototype.set |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Sep 22, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.