That's a nice article on a topic that needed to be written up (forEach v map). Very nice that you provided actual reasons for using one or the other. I notice that a lot of people just use map() because it is the newest and shiniest, but forEach() still has its place. 👍🏽
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
That's a nice article on a topic that needed to be written up (forEach v map).
Very nice that you provided actual reasons for using one or the other. I notice that a lot of people just use map() because it is the newest and shiniest, but forEach() still has its place. 👍🏽
Thank you for the support :)
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
Great explanation!
Thanks👌🏽
Thanks! Let me know if there's some topic you want me to cover
Great explanation
Cool explanation.
Thanks! Let me know if there's some topic you want me to cover
Clear explanation. Thanks <3
Thanks! Let me know if there's some topic you want me to cover
Great work