What does { content: [Circular] } mean in JavaScript?

后端 未结 3 423
萌比男神i
萌比男神i 2020-12-17 16:18

My code was:

var chineseBox = {};
chineseBox.content = chineseBox;

and it returned:

{ content: [Circular] }
3条回答
  •  星月不相逢
    2020-12-17 16:48

    Your object contains a circular reference. If you tried to print (or serialize) this object you would end up in an infinite loop

    {content: {content: {content ...
    

    Instead, your system was smart enough to notice the circularity and protect itself against it.

提交回复
热议问题