The real reason why JavaScript has arrow functions

Martin Novak
Frontend Weekly
Published in
4 min readOct 19, 2020

--

Took arrow function in the knee
Took arrow function in the knee!

Nowadays, all my code is based on the use of arrow functions. If you are still not using them yourself, then don’t be ashamed of who you are. That’s your parent’s job. Instead, find about all the benefits that you can get by using arrow functions like the cool kids.

This is an example of arrow function and the same code written traditionally:

You may notice that the code is shorter and that there is an arrow. Everything before the arrow is arguments of the function and everything after the arrow is always returned as the result of the function.

If you need a function that contains multiple statements you can still do this:

--

--

Martin Novak
Frontend Weekly

Martin is a product manager at work, a software developer in his free time, and an entrepreneur at heart.