Q:

Memory allocation and DOM elements

While reading an MDN article about Memory Management (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Memory_Management) I came upon the following question: Is it right to say that 
var e = document.getElementById('div_id'); 

allocates a DOM element? I am using the same words with MDN article. In my opinion this is not right since the element-object with id="div_id" is already created in memory as part of the DOM tree. So var e, just references it and does not allocate new memory. Am I right or not?
Thank you

A:

document.getElementById('div_id') will not allocate memory for the element, as it already exists in the document tree.
However, the article you have linked doesn't actually say that memory would be allocated. So I don't see anything wrong with the article.
The only memory that gets allocated is for the variable e of the expression var e = document.getElementById('div_id');. This allocation happens in the stack. A new reference to the element is assigned to e, which consumes memory (even though it's a very small amount). No new memory allocation happens in the heap.

