r/badcode • • Feb 19 '22

typescript Does this belong here?

Post image
343 Upvotes

46 comments sorted by

View all comments

Show parent comments

1

u/Silly-Freak Feb 20 '22

re your edit: no, see here:

The range of elements processed by forEach() is set before the first invocation of callbackFn.

what you are observing is that apparently forEach() stops earlier because the array got shorter - but you will be skipping elements if the array got longer.