A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakSet/WeakSet below:

WeakSet() constructor - JavaScript | MDN

WeakSet() constructor

Baseline Widely available

The WeakSet() constructor creates WeakSet objects.

Syntax
new WeakSet()
new WeakSet(iterable)

Note: WeakSet() can only be constructed with new. Attempting to call it without new throws a TypeError.

Parameters
iterable Optional

If an iterable object is passed, all of its elements will be added to the new WeakSet. null is treated as undefined.

Examples Using the WeakSet object
const ws = new WeakSet();
const foo = {};
const bar = {};

ws.add(foo);
ws.add(bar);

ws.has(foo); // true
ws.has(bar); // true

ws.delete(foo); // removes foo from the set
ws.has(foo); // false, foo has been removed
ws.has(bar); // true, bar is retained

Note that foo !== bar. While they are similar objects, they are not the same object. And so they are both added to the set.

Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4