I'm Disgusting Dev - interested in CaaS (Codebase as a Service) solution and willing to increase knowledge of Dev Community about different problems and their solutions
Just a quick note here: forEach is mutable - means he operates with the same piece of memory, allocated for defined array, but giving some CPU resources for restructuring this piece after some changes in loop
map is immutable - means it just allocates new place in memory for your results, where RAM is giving storaging resources and CPU does much less
So there is always a choice if you need to calculate slower but to save some memory, or vice-versa
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Just a quick note here:
forEach is mutable - means he operates with the same piece of memory, allocated for defined array, but giving some CPU resources for restructuring this piece after some changes in loop
map is immutable - means it just allocates new place in memory for your results, where RAM is giving storaging resources and CPU does much less
So there is always a choice if you need to calculate slower but to save some memory, or vice-versa