+ 1

How is parent node property implemented in Java Script?

I'm just curious , as every node in DOM is an object and so is the root element Document, parent node property is what links them to their parents object. How is parent node property implemented in JavaScript ? A simple example code would be helpful...thnx .

11th Apr 2021, 2:30 PM
Mons Joseph
Mons Joseph - avatar
2 ответов
+ 2
The parentNode property is simply a reference to the parent. It's not the parent or a copy of it, it is just a 'reference' https://code.sololearn.com/cTBNNd10GoZi/?ref=app Of course, here we're talking about references. But most browser engines are implemented in C++, so you can imagine how the the parentNode property is a pointer to the parent.
11th Apr 2021, 3:22 PM
XXX
XXX - avatar
+ 1
Think of the DOM as a tree where each node is like a branch or leaf. The browser's engine builds and manages this tree, keeping track of how each node is connected to its parent and children.
27th Jul 2024, 1:12 PM
Sanjeet Singh
Sanjeet Singh - avatar