title: why did console.log seem to cause memory leaks in Chrome?
body: <p>I have a function <code>a</code> where there is a function <code>b</code> that references <code>foo</code> in its closure.</p>
  <pre class="lang-js prettyprint-override"><code>class Foo {}
  
  function a() {
    const foo = new Foo()
     const b = () =&gt; {
          foo // referencing `foo`
      }
      b()
  };
  
  a() // no memory leaks
  </code></pre>
  <p>after I executed <code>a</code>, there are no memory leaks for <code>Foo</code>.</p>
  <p>I also tweaked it slightly. Still, no memory leaks for the following examples.</p>
  <pre class="lang-js prettyprint-override"><code>class Foo {}
  
  function a() {
    const foo = new Foo()
     const b = () =&gt; {
          if(foo === 'foo') {
              
          }
      }
      b()
  };
  a() // no memory leaks
  </code></pre>
  <pre class="lang-js prettyprint-override"><code>
  class Foo {}
  
  function a() {
    const foo = new Foo()
     const b = () =&gt; {
          console.log(foo.lol)
      }
      b()
  };
  a() // no memory leaks
  
  </code></pre>
  <p>But as soon as I logged out <code>foo</code>, it causes memory leaks.</p>
  <pre class="lang-js prettyprint-override"><code>class Foo {}
  
  function a() {
    const foo = new Foo()
     const b = () =&gt; {
          console.log(foo)
      }
      b()
  };
  a() // memory leaks
  </code></pre>
  <p><a href="https://i.stack.imgur.com/xu3O1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xu3O1.png" alt="enter image description here" /></a></p>
  <p>My question is why <code>console.log(fii)</code> leaks but referencing <code>foo</code> in other ways or log out its property <code>console.log(foo.lol)</code></p>
  <p>I tested these in Chrome 103 DevTool console.</p>