Difference between regular functions and arrow functions
This article discusses the major differences between the regular functions and the arrow functions.
Syntax of regular functions:-
Example of regular functions:-
The syntax of arrow functions:-
Example of arrow functions:-
Use of this keyword
Unlike regular functions, arrow functions do not have their own
Arguments objects are not available in arrow functions, but are available in regular functions.
Example using regular ():-
Example using arrow ():-
Regular functions created using function declarations or expressions are ‘constructible’ and ‘callable’. Since regular functions are constructible, they can be called using the ‘new’ keyword. However, the arrow functions are only ‘callable’ and not constructible. Thus, we will get a run-time error on trying to construct a non-constructible arrow functions using the new keyword.
Example using regular function:-
Example using arrow function:-
For more information on arrow functions, refer this link.