WeakMap.prototype.set()
set()
メソッドは、指定されたキーと値をもつ新しい要素を WeakMap
オブジェクトへ追加します。
試してみましょう
構文
wm.set(key, value);
引数
返値
WeakMap
オブジェクトです。
例
set() メソッドの使用
js
var wm = new WeakMap();
var obj = {};
// Add new elements to the WeakMap
wm.set(obj, "foo").set(window, "bar"); // chainable
// Update an element in the WeakMap
wm.set(obj, "baz");
仕様書
Specification |
---|
ECMAScript Language Specification # sec-weakmap.prototype.set |
ブラウザーの互換性
BCD tables only load in the browser