Advertisement
Guest User

Untitled

a guest
Jun 30th, 2015
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1.  
  2. // HTMLCollection from getElementsByTagName and getElementsByClassName methods
  3.  
  4. var a = document.getElementsByTagName('div');
  5. console.log( ({}).toString.call(a) ); // "[object HTMLCollection]"
  6. console.log(typeof a.map); // "undefined"
  7. a = [].slice.call(a); // convert
  8. console.log(typeof a.map); // "function"
  9.  
  10. // NodeList from querySelectorAll
  11.  
  12. var b = document.querySelectorAll('div');
  13. console.log( ({}).toString.call(b) ); // "[object NodeList]"
  14. console.log(typeof b.map); // "undefined"
  15. b = [].slice.call(b); // convert
  16. console.log(typeof b.map); // "function"
  17.  
  18. // childNodes is a NodeList
  19.  
  20. var c = document.getElementsByTagName('body')[0].childNodes;
  21. console.log( ({}).toString.call(c) ); // "[object NodeList]"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement