Node does not contain dom and bom; bom refers to the browser object model, bom refers to the document object model, and node uses ecmascript for encoding, and there is no browser or document. It is an environment platform where JavaScript runs on the back end, so node does not include dom and bom.
The operating environment of this article: Windows 10 system, nodejs version 16, Dell G3 computer.
Encoding using ecmascript in node
There is no bom and dom, which is different from js in the browser
First make two points clear:
1. BOM (Browser Object Model) refers to the browser object model, which can access and operate the browser window.
2. DOM (Document Object Model) refers to the document object model, through which all elements of the HTML document can be accessed.
Please see, your question can be answered based on the above two points.
There is no browser or documentation in node. Node is a back-end language, similar to PHP.
If you want to use BOM and DOM objects in NODE, you can try Electron.
Electron: uses JavaScript, HTML and CSS to build cross-platform desktop applications. (BOM and DOM can be used here)
Expand knowledge
1. DOM Document Object Model: It is a standard programming interface for processing extensible markup language recommended by the W3C organization.
DOM (Document Object Model) is the application programming interface (API) for HTML and XML.
HTML documents can be said to be a collection of nodes. DOM nodes include: element nodes, text nodes, and attribute nodes (i.e., element tags).
2. BOM browser object model: A model used to describe the hierarchical relationship between objects. The browser object model provides an object structure that is independent of content and can interact with the browser window.
The BOM primarily deals with browser windows and frames, but often browser-specific JavaScript extensions are considered part of the BOM.
BOM contains DOM (object).
javacsript accesses, controls, and modifies the client (browser) by accessing the BOM (Browser Object Model) object.
3. Node attribute nodeName; node name nodeType; node type nodeValue; traverse the node tree childNodes;
Node node characteristics and methods
firstChild //Node, points to the first node in the childNodes list lastChild //Node, points to the last node in the childNodes list parentNode //Node, points to the parent node ownerDocument //Document, points to the document to which this node belongs firstChild / /Node, points to the first node in the childNodes list lastChild //Node, points to the last node in the childNodes list parentNode //Node, points to the parent node childNodes //NodeList, a list of all child nodes previousSibling /Node, / Points to the previous sibling node: If this node is the first node, then the value is null `nextSibling` //Node, points to the next sibling node: If this node is the last node, then the value is null `hasChildNodes() ` //Boolean, returns true when childNodes contains one or more nodes3. DOM has two event models at the same time: bubbling events and capturing events
Bubbling events: Events are triggered in order from the most specific event target to the least specific event target.
(The order of triggering is: div, body, html (IE 6.0 and Mozilla 1.0), document, window (Mozilla 1.0))
Capturing events: The opposite process to bubbling events. Events are triggered from the least accurate object, and then to the most accurate. The order of triggering in the above example is: document, div
Recommended learning: "nodejs video tutorial"
The above are the details of whether node contains dom and bom. For more information, please pay attention to other related articles on this site!