Is there a way to test if two (or more) WeakSets are equal? So, I want this code to print out true
var a = new WeakSet();
var b = new WeakSet();
a.add([3]);
b.add([3]);
console.log(isEqual(a, b)); // -> true
Is there a way to test if two (or more) WeakSets are equal? So, I want this code to print out true
var a = new WeakSet();
var b = new WeakSet();
a.add([3]);
b.add([3]);
console.log(isEqual(a, b)); // -> true
Simple answer - you can't. WeakSet
s are not enumerable so there is no way to test the equality of values in a WeakSet
.
Currently your only option is to use Array
here.
Check out this answer.
Also see this proposal if you want to use Set
instead.
Though I doubt that your use case requires that kind of memory management, you may also consider WeakReferences as part of your solution.
As a side note, WeakSet
s have very few actual use-cases, so you probably should not settle for them.