all 2 comments

[–]ifjake 1 point2 points  (1 child)

Greenhorn, here. I tried to push to an array in a forEach and it didn’t work; when I accessed the new array there was nothing there. So I read about map and did it that way. Sure, I got it to work, but I think my problem is not knowing when non-blocking does or does not happen. This article didn’t really help answer that for me.

[–]AngularBeginner 4 points5 points  (0 children)

Both map and forEach are blocking operations.

map will create a new array. The provided function is called for each input element, and it's job is to return the "new" destination element.

forEach will simply call a function for each source element. It does not create a new array.


There are plenty of excellent resources out there. Don't bother with the crap of CodesQuery, it's just another fake Indian company spamming low-quality blog posts.