Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a node in Javascript?

I was wondering what exactly a node is in JavaScript?

As in the functions:

element.nodeType row.parentNode.removeChild(row); 
like image 922
jaredramirez Avatar asked Jul 26 '14 19:07

jaredramirez


People also ask

What does node mean in JavaScript?

Node. js (Node) is an open source development platform for executing JavaScript code server-side. Node is useful for developing applications that require a persistent connection from the browser to the server and is often used for real-time applications such as chat, news feeds and web push notifications.

What is Node JS example?

Node. js is a platform built on Chrome's JavaScript runtime for easily building fast and scalable network applications. Node. js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices. Node.

Why is JavaScript called node?

The official name is actually Node . Originally it was designed for use as a web application, but the author realized it could be used for more general purposes and renamed it to node.


2 Answers

A "node", in this context, is simply an HTML element. The "DOM" is a tree structure that represents the HTML of the website, and every HTML element is a "node". See Document Object Model (DOM).


More specifically, "Node" is an interface that is implemented by multiple other objects, including "document" and "element". All objects implementing the "Node" interface can be treated similarly. The term "node" therefore (in the DOM context) means any object that implements the "Node" interface. Most commonly that is an element object representing an HTML element.

like image 172
Hubro Avatar answered Oct 08 '22 20:10

Hubro


Nodes are in the DOM aka Document Object model. In the DOM, all parts of the document, such as elements, attributes, text, etc. are organized in a hierarchical tree-like structure; consisting of parents and children. These individual parts of the document are known as nodes.

enter image description here

The topmost node is the root node (Document Node) of the DOM tree, which has one child, the <html> element and so on. Further, the text content inside an element is a child node of the parent element, for example, "Mobile OS" is considered as a child node of the <h1> that contains it, and so on. Comments inside the HTML document are nodes in the DOM tree as well even though they dont effect the document in any way. HTML attributes such as id, class, title, style, etc. are also considered as nodes in DOM hierarchy.

like image 45
Yahya Rehman Avatar answered Oct 08 '22 19:10

Yahya Rehman