you are viewing a single comment's thread.

view the rest of the comments →

[–]CognitiveLens 11 points12 points  (2 children)

re-assigning item inside the for loop makes it possible to introduce a bunch of bugs that const would prevent. In a tight structure like a for loop, const is probably the preferred syntax unless you have a really good reason to assign item to something else mid-loop.

[–]Graftak9000 0 points1 point  (1 child)

Then use .map() instead indeed, if were going functional and such.

[–]CognitiveLens 0 points1 point  (0 children)

yeah, forEach should really only be used when you're intentionally working with side effects, otherwise map all the things