DEV Community

Discussion on: Using arrow functions might be costing you performance

Collapse
 
karataev profile image
Eugene Karataev

Actually jsPerf shows that arrow functions with implicit return are the fastest.

Functions comparision

But the difference in performance is so small, that it shouldn't be taken into account when deciding what type of function to use.

Collapse
 
jgaskins profile image
Jamie Gaskins

Agreed. With a difference of 1.5M operations per second, and assuming a screen refresh time of 16.66 (that's repeating, of course) milliseconds, you would have to execute 250K of the faster option changed to the slower one to make a noticeable difference even to a professional Starcraft player.

Collapse
 
sleeplessbyte profile image
Derk-Jan Karrenbeld

This might be more interesting to compare: jsperf.com/fufufufu/3

Collapse
 
karataev profile image
Eugene Karataev

In my test run the results are almost the same for all three tests (ops/sec varies +-1%).

Thread Thread
 
sleeplessbyte profile image
Derk-Jan Karrenbeld

That is the point ;)

This article is pretty fear mongering and statistically incorrect 🤓.

  • Don't worry about using arrow function expressions
  • Don't worry about using implicit return

In the same line:

  • Don't worry about relying on Automatic Semicolon Insertion
  • Don't worry about using "class"es or (other) prototype-inheritance

The bottleneck of the code is not going to be in the syntax one uses.

Thread Thread
 
karataev profile image
Eugene Karataev

Agree!

Collapse
 
pattisano profile image
Philip Attisano

👆 This comment.
You sir just destroyed the entire article . . . take a bow.