<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<ul>
<li>hello 1</li>
<li>hello 2</li>
<li>hello 3</li>
</ul>
<script>
function* search(node) {
if (!node) return;
yield node;
yield* search(node.firstChild);
yield* search(node.nextSibling);
}
document.body.insertAdjacentHTML("beforeend", `<h1> the DOM`)
const nodes = [];
for (let node of search(document.body)) {
if (node.localName) nodes.push(node.localName)
}
document.body.insertAdjacentHTML("beforeend", nodes)
</script>
</body>
</html>