title: Is inline javascript garbage collected when document body is replaced?
body: <p>Consider I have the below webpage written in HTML (body section only):</p>
  
  <pre><code>&lt;body&gt;
      &lt;p&gt;
          ...
      &lt;/p&gt;
  
      &lt;script&gt;
          function fn() {
              // do stuff
          }
      &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>Now, if I replace the <code>innerHTML</code> of <code>document.body</code> from JavaScript with say, a div, so that the body part becomes:</p>
  
  <pre><code>&lt;body&gt;
      &lt;div&gt;
          ...
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>... then is the <code>fn</code> object <em>eligible</em> for garbage collection if no references to it exist anywhere in the rest of the code (any context)?</p>