0

Recently, I wrote a script in JavaScript where I did same thing with map function and for loop. All other environment was same as well. However the execution time of map function was significantly greater than the simple loop. Is it true that a simple loop is faster than map function or was I doing something wrong?

MRX
  • 1
  • Sure, the loop is probably faster but I wouldn't worry about this sort of micro optimization. Is this really the bottleneck of the app? Are your customers affected? If not, I'd [worry about more important stuff](https://ericlippert.com/2012/12/17/performance-rant/). Also, when you're talking about performance like this, please share your actual benchmark code and describe your test environment, because it's really easy to mess up or introduce some detail that you haven't mentioned but winds up changing the whole ballgame. – ggorlen May 23 '21 at 03:25
  • My apologies for not uploading the code and describing test environment. Totally agreed. Thank you – MRX May 24 '21 at 04:22

0 Answers0