In memory constrained devices the use of .map() is not always possible. In such places, this should determine whether a mutation is better than creating a new array from scratch while emptying the original array, thus, keeping somewhat the same memory usage.
Comparing performance of: Mutate array vs Memory efficient map
Memory measurements supported only in Chrome.
For precise memory measurements Chrome must be launched with --enable-precise-memory-info flag.
More information: Monitoring JavaScript Memory
Test case name
Result
Mutate array
Memory efficient map
Fastest:N/A
Slowest:N/A
Latest run results:
Run details: (Test run date:
one month ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36