3 ms·
I write a lot of JavaScript and have never decided on using .forEach over something else. I have never used it. Nor have I, or will I, use yield / generators, b
by stupidmoron 5y ago
I write a lot of JavaScript and have never decided on using .forEach over something else. I have never used it. Nor have I, or will I, use yield / generators, because they are confusing and silly, which is why nobody uses them. I don't believe these things will make you write better JavaScript, but rather, worse JavaScript.
- scrapheap 5y agoThese things are all just tools in the programmer's tool box. Which one you use will come down to the one you think is most suitable at the time based on your knowledge and experience. Generators are very useful in more complex scenarios, but when used in simpler environments they'll just add confusion - in fact the article is a good example of adding confusion with a Generator. Personally, when dealing with arrays I favour using .map, .reduce, .filter and .forEach.
- dan-robertson 5y agoI think forEach was a lot more compelling when for(… of …) wasn’t widely supported
- Waterluvian 5y agoGenerators are fundamentally important to have to solve a number of problems. But like me, you probably never need them because you aren’t solving those problems.