The typescript array contains objects with circular references. How do you get rid of those duplicate objects?

such as the title, read a lot of weight removal methods on the Internet, but they are not suitable for my situation, solve! Thank you!

Apr.09,2022

what exactly does your so-called circular reference object look like?

regular array deweighting, I array to set, and back to array. It is easy to write, but it is not clear whether the performance is good or not

class Greeter {
    greeting: string;
    constructor(message: string) {
        this.greeting = message;
    }
    greet() {
        return "Hello, " + this.greeting;
    }
}

const a = new Greeter('1');
const b = new Greeter('2');
const c = new Greeter('3');

const myArr = [a, a, a, a, b, c, c, c, b, c, c, b, b, b, b, c, c, a, a, a, a];

const mySet = new Set(myArr);

const finalArr = Array.from(mySet);
console.log(finalArr)
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b42340-2bd70.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b42340-2bd70.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?