Standard built-ins

WeakRef

Try the free JavaScript compiler

Create weak access to an eligible target; does not establish a collection deadline. Do not depend on weak access for critical cleanup.

Formal Syntax & Structure

javascript syntaxjavascript
new WeakRef(target)

Parameters & Attributes

NameTypeDescription
targetObject | nonregistered SymbolEligible target.

Return Value

WeakRef

New weak reference.

Working Example

Example Snippetjavascript
const x={};console.log(new WeakRef(x).deref()===x);
JavaScript Reference