Arrow functions are preety cool 😎 . They help you make code shorter, which gives less room for errors to hide. They also help you write code that's easier to understand once you get used to the syntax.
The Syntax.
Arrow function is denoted by (=>) . In ES6 its a new way to make anonymous function.
_ Normal function : _
const normalFunction = function (arg1, arg2) {
// pls do something
}
Arrow function
// Arrow Function
const arrowFunction = (arg1, arg2) => {
// pls do something
}
Steps to convert normal function to arrow function.
1) Remove function keyword from a normal function .
2) Add => after the parenthesis to get an arrow function.
Happy Learning
Top comments (0)