WeakRef()
WeakRef() is a JavaScript function in the WeakRef category. Creates a weak reference. The syntax is new WeakRef(target). A typical example: new WeakRef({x:1}). A close sibling is WeakRef.prototype.deref(), which returns the referenced object or undefined. A close sibling is WeakSet.prototype.has(), which checks for object. A close sibling is WeakSet.prototype.delete(), which removes an object. A close sibling is WeakMap.prototype.has(), which checks for key. More about this category: WeakRef and FinalizationRegistry. Related WeakRef methods: WeakRef.prototype.deref(), WeakSet.prototype.has(), WeakSet.prototype.delete(), WeakMap.prototype.has(), WeakMap.prototype.delete(). This page is part of the free JS Reference documentation covering 1027+ methods, each with syntax, parameters, return values, examples, and common pitfalls. You can try WeakRef() immediately in the JavaScript playground, look up unfamiliar terms in the glossary, or return to the JS Reference homepage.