Arrow Functions

Natalia Wit
1 min readDec 13, 2020

What are arrow functions?

In the above example, you can see that arrow functions are related to using =>. Arrow functions are invoked just like regular standard functions.

Arrow functions just like regular standard functions have their body aka (block body) declared inside of brackets {}. The functions params are always declared in the parenthesis before the fat arrow as to which it points to the body of the function. When you are using brackets {} you will have to use an explicit return statement just like the regular standard functions. What’s also great with arrow functions is that you can implicitly return the body of a function, which means you can omit the curly braces and write your code in one line. See below:

*Please note that the additionImplicit() function will only work if it's written in one line

We can also omit the parenthesis in the arrow functions for the parameters if there is only one parameter. See below:

Arrow functions are great when you use methods such as map and reduce. In my opinion, it makes the code more readable. To me, the pros outweigh the cons.

Happy Coding:)

--

--