title: Do DOM objects get garbage collected in javascript?
body: <pre><code>var domElementReference = $(document.createElement('div'));
  </code></pre>
  
  <p>Will the DOM element get destroyed if I don't actually insert it on the page (once <code>domElementReference</code> gets out of scope)?</p>
  
  <p>If not: If I have a constructor-function that creates DOM elements, is there an automatic way to clear them in javascript? </p>
  
  <p>What I tought was to append them on an element, and then use </p>
  
  <pre><code>myChildNode.parentNode.removeChild(myChildNode);
  </code></pre>
  
  <p>But than again I have to manually call the function when the object is getting out of scope, and it kind of messes up the whole 'garbage-collection' idea. Any patterns to 
  automatically destroy the object?</p>