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.jsand add 1 million function definitions to the file.
- Lets create another file with name
withFunctionExpression.jsand add 1 million function definitions using expressions to the file.
- Lets create yet another file with name
withArrowDefinition.jsand add 1 million arrow functions.
withFunctionDefinitiontakes a constant time to get executed and has the best overall performance.
- The time complexity of files
withArrowDefinitiongrows linearly alongwith number of functions defined in the file (and both are similar)