When writing JavaScript, when would you use ES6 arrow functions? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

When writing JavaScript, when would you use ES6 arrow functions?

I have just started using arrow functions and have been wondering, when should they be used in general?

7th Sep 2019, 12:49 AM
Edwin Pratt
Edwin Pratt - avatar
5 Answers
+ 3
In Array methods such as map, reduce, filter, sort like this https://code.sololearn.com/WskmXTGm7M47/?ref=app
7th Sep 2019, 3:49 AM
Gordon
Gordon - avatar
+ 2
Like you use function or return in older version, pretty clear and simple
8th Sep 2019, 6:44 AM
yegon kiprotich
yegon kiprotich - avatar
+ 2
Thanks for clearing up my question Gordon and yegon kiprotich!
10th Sep 2019, 1:54 AM
Edwin Pratt
Edwin Pratt - avatar
+ 1
Arrow functions shine best with anything that requires 👉 ’this’ to be bound to the context, and not the function itself. It is important to note that arrow functions are anonymous, which means that they are not named. YOU should not use Arrow functions 1) Object methods 2) Callback functions with dynamic context. 3) when it makes your code less readable. thanks, Happy Coding
28th Sep 2019, 11:37 AM
Suraj Patil
Suraj Patil - avatar
+ 1
Arrow functions works well for callback functions. In general, I find arrow functions more succinct and easy to work with.
28th Sep 2019, 2:20 PM
Efosa Igbinehi
Efosa Igbinehi - avatar