title: How does Javascript avoid infinite callback invocation?
body: <p>I have the following code. </p>
  
  <p>html</p>
  
  <pre><code>&lt;p id="test"&gt;hello&lt;/p&gt;
  </code></pre>
  
  <p>javascript</p>
  
  <pre><code>document.getElementById("test").addEventListener("click", function() {
    console.log("called");
    document.getElementById("test").click();
  });
  
  document.getElementById("test").click();
  </code></pre>
  
  <p>When I run it, the console only print "called" once. My question is what mechanism does javascript use to avoid calling the callback infinitely?</p>