add(key)
|
添成员并返回Set本身
|
has(key)
|
通过 键 判断 成员 是否存在
|
delete(key)
|
通过 键 移除 成员
|
const obj1 = { name: "tom" }; const ws = new WeakSet(); const wm1 = ws.add(obj1); // 添加成员并返回WeakMap本身 console.log(ws, wm1); console.log(ws.has(obj1)); // 通过 键 判断 成员 是否存在 ws.delete(obj1) // 通过 键 移除 成员 console.log(ws);