Guest User

Untitled

a guest
May 26th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. (function bfs() {
  2. var root = document.querySelectorAll(':root');
  3. let queue = [root];
  4. let count = 0;
  5. while(queue.length){
  6. let domList = queue.pop();
  7. domList.length && (count+= domList.length);
  8. if(domList && domList.length){
  9. for(let i=0;i<domList.length;i++){
  10. queue.push(domList[i].childNodes);
  11. }
  12. }
  13. }
  14. console.log(count);
  15. })();
Add Comment
Please, Sign In to add comment