Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function bfs() {
- var root = document.querySelectorAll(':root');
- let queue = [root];
- let count = 0;
- while(queue.length){
- let domList = queue.pop();
- domList.length && (count+= domList.length);
- if(domList && domList.length){
- for(let i=0;i<domList.length;i++){
- queue.push(domList[i].childNodes);
- }
- }
- }
- console.log(count);
- })();
Add Comment
Please, Sign In to add comment