4 ms·
You don't need Array.from this works fine: document.querySelectorAll('.age').forEach(el => el.style.display = 'none') But I didn't have to do anything lik
by bufferoverflow 4y ago
You don't need Array.from this works fine:
document.querySelectorAll('.age').forEach(el => el.style.display = 'none')
But I didn't have to do anything like that in years. With reactive frameworks you just bind visibility and styles to variables, refs or some central state.
- Spivak 4y agoI think that was to handle older browsers. https://caniuse.com/mdn-api_nodelist_foreach https://caniuse.com/mdn-api_nodelist_foreach looks pretty good but it didn't used to.
- deleted 4y ago[deleted]
- tambourine_man 4y ago> With reactive frameworks you just bind visibility and styles to variables, refs or some central state I fail to see the superiority of that approach after more than a decade. To me, the success of React and the likes has more to do with team dynamics, hiring, etc.
- bufferoverflow 4y agoI easily see the superiority. The data controls the UI, instead of some random line of code that's very hard to find. Essentially it's declarative programming, you declare your UI should look this way when the state is this, and that way when the state is that. It's much easier to reason about than when you have a thousand random functions that can change the UI, often in ways that break each other.
- tambourine_man 4y agoThat’s what I meant by team dynamics. I can separate concerns instead of multiple functions changing the same UI, but I can’t guarantee that everyone else will. The conventions that React provides sidesteps the need for discipline and that I find useful. Doesn’t mean that the approach in itself is better, IMO. and if you work alone, it’s clearly way too much trouble for little gain.