node types code example

Example 1: js node type

//The read-only Node.nodeType property is an integer that identifies what the node is. It distinguishes different kind of nodes from each other, such as elements, text and comments.

var x = document.getElementById("ElementID").nodeType;

//Returns an integer which specifies the type of the node
/*
Example
1.  Element
2.  Attribute
3.  Text
4.  CDATASection
5.  EntityReference
6.  Entity
7.  ProcessingInstruction
8.  Comment
9.  Document
10. DocumentType
11. DocumentFragment
12. Notation 
*/

Example 2: npm for node types

npm i @types/node