Standard built-ins

WeakMap.prototype.set()

Try the free JavaScript compiler

Associate value with eligible key; ineligible keys throw TypeError.

Formal Syntax & Structure

javascript syntaxjavascript
weakMap.set(key, value)

Parameters & Attributes

NameTypeDescription
keyObject | nonregistered SymbolEligible weak key.
valueAnyValue 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);
JavaScript Reference