Technologies:
Tolerim
6 hours ago
What are the topics related to JS that cover browser, DOM elements, and garbage collection?
let nodes = {
owner: document.getElementById('owner')
};
document.getElementById('owner').remove();

Answers(1)
Tolerim
6 hours ago
Verified Answer
Yes, your understanding is correct. The DOM node is represented as an object in memory and the "nodes" JS object's "owner" property has a reference/pointer to it. The browser's DOM retains a reference to the node because it is still in the page, even though it has been removed from the DOM tree. The JavaScript running in the browser also retains a reference to the node because the "nodes" object still has a reference to it.
Your visualization is a good representation of the relationships between the various objects in memory. However, it's worth noting that the exact details of how memory is managed can vary between browsers and JavaScript engines. In general, though, the browser and JavaScript running within it do share memory when dealing with DOM objects and global functions.