Home / Javascript Tips Generated By ChatGPT / Using WeakSet for Collections of Objects in Javascript Create a collection of objects that does not prevent garbage collection using WeakSet. Source Code let obj1 = {}; let obj2 = {}; let weakSet = new WeakSet([obj1, obj2]); console.log(weakSet.has(obj1)); // true