var person = {
name:'asdfds',
key:1
}
person.next = person;
How to fix this cyclic redundancy in javascript?
var person = {
name:'asdfds',
key:1
}
person.next = person;
How to fix this cyclic redundancy in javascript?
Copyright © 2021 Jogjafile Inc.
As mentioned in the comment, you can check circular reference with
===operator, following code evaluates to true:With this given information you can avoid looping endlessly by holding an
arrayofreferencesto the objects you have already looped through.This gives you the desired output of every
primitivevalue once: