News for hackers. Stuff that matters.
Re:Bootstrap 5 will remove jQuery as a dependency by nailer on Tuesday February 12, 2019 @07:43PM (#19149272)
> But looping over querySelectorAll() is painful.

Not any more:

    let elements = document.querySelectorAll('.some-class')
    elements.forEach(function(element){
      ...
    })
https://developer.mozilla.org/en-US/docs/Web/API/NodeList/fo...

PS. The other two answers here are outdated.

Re:Bootstrap 5 will remove jQuery as a dependency by Carpetsmoker on Thursday February 14, 2019 @12:56AM (#19159907)
I should have explained the use case better: I need to store an indexed array of elements for cache/querying later on; so forEach() isn't a good fit here.

Other people suggested Array.from(), but that won't work in IE, and the polyfill for it is a lot longer/more complex than the for loop I wrote.

Re:Bootstrap 5 will remove jQuery as a dependency by j79 on Tuesday February 12, 2019 @09:24PM (#19149807)
> PS. The other two answers here are outdated.

Sure, the other two answers may be "outdated" but they're still extremely useful if you're looking to calling map/filter/etc against your queried elements.

Re:Bootstrap 5 will remove jQuery as a dependency by runarberg on Wednesday February 13, 2019 @01:19AM (#19150890)
For that you can write:

    const elements = document.querySelectorAll('.some-class');
    const values = Array.prototype.map.call(elements, element => element.value);
or more idiomatically (and perhaps a little slower):

    const elements = [...document.querySelectorAll('.some-class')];
    const values = elements.map(element => element.value);
Re:Bootstrap 5 will remove jQuery as a dependency by nailer on Wednesday February 13, 2019 @03:44AM (#19151493)
They asked about looping, not mapping or filtering.
Re:Bootstrap 5 will remove jQuery as a dependency by runarberg on Tuesday February 12, 2019 @07:59PM (#19149387)
Or if you prefer:

    for (const element of document.querySelectorAll('.some-class')) {
      // ...
    }