WeakRef() 构造函数创建 WeakRef 对象。
¥The WeakRef() constructor creates WeakRef objects.
¥Syntax
注意:WeakRef() 只能与 new 一起构建。尝试在没有 new 的情况下调用它会抛出 TypeError。
¥Note: WeakRef() can only be constructed with new. Attempting to call it without new throws a TypeError.
¥Parameters
target
-
WeakRef 应引用的目标值(也称为引用对象)。必须是一个对象或 未注册符号。
¥Return value
引用给定目标值的新 WeakRef 对象。
¥A new WeakRef object referring to the given target value.
¥Creating a new WeakRef object
有关完整示例,请参阅 WeakRef 主页。
¥See the main WeakRef
page for a complete example.
class Counter {
constructor(element) {
this.ref = new WeakRef(element);
this.start();
}
}
BCD tables only load in the browser