Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js引用周期_Node.js_Reference_Cycle - Fatal编程技术网

Node.js引用周期

Node.js引用周期,node.js,reference,cycle,Node.js,Reference,Cycle,我有两门课,会计和性格。一个帐户可以有多个字符,但一个字符只属于一个帐户 class Account { constructor(){ this.characters = // Array of chars this.selectedChar = // a character object } } class Character { constructor(account){ this.account = account;

我有两门课,会计和性格。一个帐户可以有多个字符,但一个字符只属于一个帐户

class Account {
    constructor(){
        this.characters = // Array of chars
        this.selectedChar = // a character object
    }
}

class Character {
    constructor(account){
        this.account = account;
    }   
}
现在我有了一个我认为是参考周期的东西。帐户将有一个对某个字符的引用,该字符将有一个对该帐户的引用。现在我的问题是,这是否会导致性能/内存问题,如果会,我是否可以用另一种方法来解决


谢谢

我认为这样的循环没有任何问题。相互参考没有问题。垃圾收集器足够聪明,可以处理循环引用。我认为这种循环没有任何问题。相互引用没有问题。垃圾收集器足够聪明,可以处理循环引用。