This actually is a lot slower since mapping an array will create a copy of each value in order to not modify the original array.
Since a for loop does not copy the values but rather just accesses them using their index, it is a lot faster.
This peformance difference is only noticable when you have a large amount of data. For smaller amounts of data, it's better to write code which feels more natural to you, which may explain why map is used so commonly.
Thanks for the perspective. I'm going to try out the same test with creating a copy of each value in the for loop
We're a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.