JSFiddle - React, Tailwind, and code Playground

HTML

<!-- comment1 -->
<!-- comment2 -->
<!---->
<!-- -->
<!-- <!DOCTYPE html> -->

JavaScript

var docType = document.firstChild;

var children = document.body.childNodes;
console.log(isDocType(docType));
for (var i = 0; i < children.length; i++) {
    if (children[i].nodeType === 8) {
        console.log(isDocType(children[i]));
    }
}


function isDocType(node) {
    return node && (
    node.nodeType === 10 || (node.nodeType === 8 && "innerHTML" in node && node.innerHTML === ""));

}