Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> to be able to apply some transformation to all elements without having to write a for, or make use Array.from and then use forEach.

This has worked for many years. I typically add a shorthand $ for the QSA part and on projects where I used to support IE11 you could add Array.from there but I haven’t bothered since IE was deprecated. jQuery does more but some of those things had performance impacts which were worth thinking about and the combo of QSA and fetch took care about about 90% of my projects.

document.querySelectorAll("div").forEach(i => i.innerText = "test")



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: