Tin mới
JavaScript: Scripting language
Web APIs: Programming interfaces
Structuring content with HTML module
Dynamic scripting with JavaScript module
A WeakSet is a collection of garbage-collectable values, including objects and non-registered symbols. A value in the WeakSet may only occur once. It is unique in the WeakSet's collection.
Values of WeakSets must be garbage-collectable. Most primitive data types can be arbitrarily created and don't have a lifetime, so they cannot be stored. Objects and non-registered symbols can be stored because they are
The constructor function that created the instance object. For WeakSet instances, the initial value is the WeakSet constructor.
The initial value of the [Symbol.toStringTag] property is the string "WeakSet". This property is used in Object.prototype.toString().
The initial value of the [Symbol.toStringTag] property is the string "WeakSet". This property is used in Object.prototype.toString().
Inserts the specified value into this set, if it is not already present.
Inserts the specified value into this set, if it is not already present.
Inserts the specified value into this set, if it is not already present.
Functions that call themselves recursively need a way of guarding against circular data structures by tracking which objects have already been processed.
This page was last modified on Sep 22, 2025 by MDN contributors.