This time I will show you how to use js to count the number of page tags, and what are the precautions for using js to count the number of page tags. The following is a practical case, let's take a look.
The specific code is as follows:function fold(node){ var map = new Map(); map.set(node.tagName,1); [].reduce.call(node.children,(acc,child)=>{ deal(acc,fold(child)); return acc },map) return map } function deal(srcMap,tarMap){ tarMap.forEach((value,tagName)=>{ var newV = value + ~~srcMap.get(tagName); srcMap.set(tagName,newV); }) }
The above is the detailed content of How to use js to count the number of page tags. For more information, please follow other related articles on the PHP Chinese website!