Why do they write everywhere that NodeList has no forEach method (like an array)? For example, here https://developer.mozilla.org/ru/docs/Web/API/NodeList

If you take this code

<div class="one">One</div> <div class="one">Two</div> <div class="one">Three</div> 

then forEach works for him

  var nodeList = document.querySelectorAll('.one'); var list = nodeList.forEach(function(x){ console.log(x.innerHTML); }) // One, Two, Three 

because in proto NodeList forEach present

  • Maybe they mean that it is not in some old versions of JS? Maybe it was added in new versions. - Arty OneSoul
  • developer.mozilla.org/en-US/docs/Web/API/NodeList - it’s best to always read the docks in English. Because in other languages ​​may be outdated information. - Stepan Kasyanenko Sep.
  • Yes, indeed in the English version it is written that such a method exists. Thank! - Alex Kern

0