+ 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?
5 Respostas
+ 3
In Array methods such as map, reduce, filter, sort
like this
https://code.sololearn.com/WskmXTGm7M47/?ref=app
+ 2
Like you use function or return in older version, pretty clear and simple
+ 2
Thanks for clearing up my question Gordon and yegon kiprotich!
+ 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
+ 1
Arrow functions works well for callback functions. In general, I find arrow functions more succinct and easy to work with.