I decided to assess all of my for loops in my project to see if I could replace it with an Array.prototype
method - 75% of them could easily be replaced. Before I started the replacements, I thought I might run some tests. Most prototype methods were significantly slower (~80%) than polyfills on my machine.
Each of these tests are faster with a regular for loop
Array.prototype.find
vs. for loopArray.prototype.concat
vs for loopArray.prototype.filter
vs for loopArray.prorotype.forEach
vs for loopArray.prototype.map
vs for loopArray.prototype.reduce
vs for loopArray.prototype.some
vs for loop
I did not have the time to look up other jsperf tests, but i'm sure most prototype methods will be slower. So why? These functions are very useful, but how come they are so much slower than simple for loops.
Chrome 60.0.3112 / Windows 10 0.0.0