Standard built-ins
WeakMap.prototype.set()
Associate value with eligible key; ineligible keys throw TypeError.
Formal Syntax & Structure
javascript syntaxjavascript
weakMap.set(key, value)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| key | Object | nonregistered Symbol | Eligible weak key. |
| value | Any | Value to associate or insert. |
Return Value
WeakMap
Same map.
Working Example
Example Snippetjavascript
const k={};const w=new WeakMap();console.log(w.set(k,2)===w);