Why are arrow functions used in ES6?
Arrow functions are one of the major reasons for the popularity of ES6 due to the reasons mentioned below:
- Safety of scope: Consistent use of arrow functions guarantee to use the same thisObject as the root. Using the arrow functions provides scope safety because even if a single standard function callback is mixed with some arrow functions, the probability of scope getting disturb increases.
- Compactness: It is easier to read and write when it comes to arrow functions as compared to other functions. This provides a less complex approach of using ES6 as well as the arrow functions.
- Provides clarity: A developer can easily identify what “ thisObject” is and find out the next-higher function statement after the arrow function statement if he/she uses arrow function in most of the program. It will provide huge clarity and easy detection of errors in any program.
Suggest An Answer
No suggestions Available!