let tag = [];
explore = (node) => {
for (let elt of node.children) {
tag.push(elt.nodeName);
explore(elt);
}
}
explore(document.body); //
getEleCnt = (arr) => {
return arr.reduce(function(prev,next){
prev.has(next) ? prev.set(next,prev.get(next) + 1) :prev.set(next,1);
return prev;
},new Map());
}
let allCntEle = getEleCnt(tag);
for(let [u, r] of allCntEle.entries())
console.log(`${u}: ${r}`);