Comment

Comment by megous

I prefer:

    for (let node of document.querySelectorAll("li"))
        node.classList.add('foo');
or:

    Array.from(document.querySelectorAll("li")).forEach(node => node.classList.add('foo'))
And if any particular pattern repeats in the code I'm writing I'll just create a helper function for that pattern (most of the time locally). Like:

    let qsa => s => Array.from(document.querySelectorAll(s));
There's nothing to test about that.
parent megous 9 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton