var str = document.documentElement.innerHTML.toString();       var tags = document.getElementsByTagName("*");       var arrTags = Array.prototype.slice.call(tags);       var mapStore = new Map();       for (var i = 0; i < arrTags.length; ++i){         if (mapStore.has(arrTags[i].tagName)){           var n = mapStore.get(arrTags[i].tagName);           mapStore.set(arrTags[i].tagName, n+1);         }else{           mapStore.set(arrTags[i].tagName, 1);         }       }       var index = 1, str;       for (var [key, value] of mapStore){         if (value > index){           str = key;         }       }       console.log(`the tag is ${str}, and the num is ${mapStore.get(str)}`);
点赞 2

相关推荐

牛客网
牛客网在线编程
牛客网题解
牛客企业服务