DEV Community


Posted on

function vs expression vs arrow definitions - Performance comparison (Part 3)

In this post we are going to compare performance of javascript functions created with function definitions vs function expressions vs arrow functions.

To test this, we created three types of files:

  • withFunctionDefinition.js - contains simple function definitions
  • withFunctionExpression.js - contains function definitions using function expression syntax
  • withArrowDefinition.js - contains function definitions with arrow syntax


  • Lets create a file with name withFunctionDefinition.js and add 1 million function definitions to the file.


  • Lets create another file with name withFunctionExpression.js and add 1 million function definitions using expressions to the file.


  • Lets create yet another file with name withArrowDefinition.js and add 1 million arrow functions.


  • File withFunctionDefinition takes a constant time to get executed and has the best overall performance.
  • The time complexity of files withFunctionExpression and withArrowDefinition grows linearly alongwith number of functions defined in the file (and both are similar)


Top comments (0)