I want to be able to implement a Set in javascript that allows me to do something like this:
const s = Set([[1,2,3], [1,2,3], 1, 2, 1]);
s.add([1,2,3]);
console.log(s);
// {[1,2,3], 1, 2}
Of course, since the === operator is used on the set, any object will not equal itself unless a reference to the same object is passed, and so instead of the above we would currently get:
Set(5) { [ 1, 2, 3 ], [ 1, 2, 3 ], 1, 2, [ 1, 2, 3 ] }
Does the following seem like a good way to implement this? What might I be missing or can improve on?
class MySet extends Set {
    constructor(...args) {
        super();
        for (const elem of args) {
            if (!this.has(elem)) super.add(elem);
        }
    }
    has(elem) {
        if (typeof elem !== 'object') return super.has(elem);
        for (const member of this) {
            if (typeof member !== 'object') continue;
            if (JSON.stringify(member) === JSON.stringify(elem))
                return true;
        }
        return false;
    }
    add(elem) {
        return (this.has(elem)) ? this : super.add(elem);
    }
    delete(elem) {
        if (typeof elem !== 'object') return super.delete(elem);
        for (const member of this) {
            if (typeof member !== 'object') continue;
            if (JSON.stringify(member) === JSON.stringify(elem))
                return super.delete(member);
        }
        return false;
    }
} 
    