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;
}
}
现在我有了一个我认为是参考周期的东西。帐户将有一个对某个字符的引用,该字符将有一个对该帐户的引用。现在我的问题是,这是否会导致性能/内存问题,如果会,我是否可以用另一种方法来解决
谢谢我认为这样的循环没有任何问题。相互参考没有问题。垃圾收集器足够聪明,可以处理循环引用。我认为这种循环没有任何问题。相互引用没有问题。垃圾收集器足够聪明,可以处理循环引用。