Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
ToshNeox2528yI used to hate arrow functions too, but it's incredibly useful to learn how to use them. They're handy because each new function() call creates a new scope for the 'this' variable, however arrow functions preserve the scope.
It will help if you do a lot of OOP-style JS and constantly have to do 'var self = 'this'.
MDN have a good article on it - it's worth reading 😊 -
Yeah, I noticed a marked decrease in readability -- even of my own code -- for the first few weeks. But your brain will adjust quickly.
(Objective-C on the other hand...) -
They're great for what they do with the 'this' keyword.
Mostly though I love them for making anonymous callback functions into simpler one-liners. Much neater code when you're working with async stuff, promises etc. -
tytho23148yThere's some extra meaning to it with lexical context that for me is the real utility with arrow functions, although it can be abused quite easily, as well as the other "syntax sugar" like destructuring and whatnot. Syntax diabetes is more like it.
-
zshh38488yYou'll get use to them. For me I don't really care for ugly verbose function declarations as written pre-ES6.
-
coookie26128yI come from scala background and when I saw arrow functions, I thought, "fucking finally, now I am home"
-
perymimon396yyour are not alone. i think they are greet in the start but overuse of them everywhere even on super long function kill the readability . because i can't tell anymore where all that functions started.
they look just as a declaration of const/let/var when i scroll fast.
and even on short arrow if i not expect function as parameter i need to read the expression three times to tokened it out and beak it into a meaningful expression
I hate arrow functions in ES6! Whenever I see them, I get acute code dyslexia and can't read shit. What the fuck is wrong with writing function, why change it for some unreadable series of symbols?
undefined
ternary isn't great either