title: How to detect circular references in JavaScript
body: <p>For example:</p>
  
  <pre><code>$ node
  &gt; var x = {}
  undefined
  &gt; x.x = x
  { x: [Circular] }
  </code></pre>
  
  <p>Wondering the sort of structures are they using to accomplish this, because it's not encoded directly into what I just did. It seems like they would do something like:</p>
  
  <pre><code>var graph = new Graph(object)
  graph.detectCircularReferences()
  </code></pre>
  
  <p>And then it would get them, but not sure how that works. Hoping to learn how to implement that.</p>