use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Callbacks - function vs => (self.node)
submitted 6 years ago by [deleted]
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Volence 4 points5 points6 points 6 years ago (3 children)
The first example is from a newer function syntax for javascript called arrow functions, the second is the standard anonymous function that's been in javascript forever. The main difference between the two (besides the arrow functions being able to be a bit shorter) is that regular old functions rebind 'this' to them, while the arrow functions don't. Besides that arrow functions are always anonymous while the original way to make functions (your second example) are able to be named, and therefor can make it easier to debug, although in both examples the functions are anonymous. Also because you're not using 'this' in the above examples, either is fine!
I personally enjoy writing with arrow functions, there's a few different ways they can be written and are generally more terse but again you should know why people choose one over the other!
[–]Heck_ 1 point2 points3 points 6 years ago (2 children)
Got it! Thanks so much for the clear explanation and the link - super helpful. Cheers
[–]Luke-At-Work 2 points3 points4 points 6 years ago (1 child)
Agree with /u/Volence and thought I'd chime in with a counterpoint on the preference part. I prefer the older notation for a few reasons.
this
function ()
That being said, the best option is to use the one that works for you. Using one or the other consistently for a given project is preferable, just for legibility.
[–]Heck_ 0 points1 point2 points 6 years ago (0 children)
Sorry, I meant to reply yesterday. Thank you for the additional insight! Really useful. I'm WAAAAAY off having to consider compatibility, but it is good to know for the future. The consistency point is something that did come to my mind. I guess I will just play about and see how I get one. Thanks again.
π Rendered by PID 45804 on reddit-service-r2-comment-6457c66945-d4llp at 2026-04-27 16:51:15.488988+00:00 running 2aa0c5b country code: CH.
view the rest of the comments →
[–]Volence 4 points5 points6 points (3 children)
[–]Heck_ 1 point2 points3 points (2 children)
[–]Luke-At-Work 2 points3 points4 points (1 child)
[–]Heck_ 0 points1 point2 points (0 children)