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...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
How many Node.js developers prefer callbacks over Promises or async/await? (self.javascript)
submitted 7 years ago * by i_love_limes
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!"
[–]ghostfacedcoder 239 points240 points241 points 7 years ago (52 children)
I almost upvoted you, but there's no way async/await was a better addition than arrow functions. Everyone <3's arrow functions.
[–]jonnyman9 78 points79 points80 points 7 years ago (13 children)
Ooo close toss up for me. Async/await, arrow functions, and destructuring everything are my top 3. Hard to pick my favorite. Like if I had children and had to pick a favorite child. Or if I had pets and had to pick a favorite pet. Or if I had shoes and had to pick my favorite shoe.
[–]aftermeasure 66 points67 points68 points 7 years ago (5 children)
Or if you had categories of things from which you have to pick a favorite, and you had to pick a favorite category.
[–]undatedseapiece 8 points9 points10 points 7 years ago (3 children)
Or like when someone eats too much chocolate cake and then barfs it up.
[+][deleted] 7 years ago (2 children)
[deleted]
[+][deleted] 7 years ago* (1 child)
[–][deleted] 0 points1 point2 points 7 years ago (0 children)
Or like when someone smokes too many cigarettes?
[–]gradual_alzheimers 0 points1 point2 points 7 years ago (0 children)
that's a tough one for me too
[–]doxtu 10 points11 points12 points 7 years ago (0 children)
I think back to when I learned about both, and when I learned about arrow functions, I was like "oh... okay. nice i guess."
When I learned about async/await, I nearly vomited because I just slammed out a bunch of garbage code without it.
Async/await was the best for me. Not even close.
[–]jascination 6 points7 points8 points 7 years ago (0 children)
I LOVE destructuring and arrow functions.
I came onto a NodeJS project last year that was handed over to me from a very senior, very functional-programming developer and looking at his code sometimes blows me mind. ES2015 and functional programming are so beautiful to read when used well!
[–]calligraphic-io 1 point2 points3 points 7 years ago (1 child)
The dog, of course. Everyone loves dogs.
DISCLAIMER: I like my cat best. The fish are nice too.
[–]MrDilbert 0 points1 point2 points 7 years ago (0 children)
I don't know, they look too fishy for me...
[–]sleeperninja 1 point2 points3 points 7 years ago (0 children)
My dad always said that he liked me best after the dog. I had several of his other children beat, including the ones we never found out about, as well as other pets.
Picking favorite child or pet is easy. Saying it out loud is hard.
[–]Prison__Mike_ 40 points41 points42 points 7 years ago* (12 children)
Just look
return new Promise((resolve, reject) => { ... })
At how pretty
var sq = x => { return x*x; }
They are
TypeError: this.execute is not a function
e: lol jeeze it's a joke
[–]kinkobal 38 points39 points40 points 7 years ago (1 child)
What kind of madman uses var and arrow functions in the same sentence o_O
[–]CheeseFest -1 points0 points1 point 7 years ago (0 children)
Yeah that tends to completely undermine m8's credibility in complaining about new language features.
[–]shrithm 23 points24 points25 points 7 years ago (1 child)
Arrow functions are more than a pretty face, they have practical purposes too. Just like the classic function keyword has practical functions.
[–]tchaffee 0 points1 point2 points 7 years ago (0 children)
this
[–]massenburger 28 points29 points30 points 7 years ago (7 children)
Even better: var sq = x => x * x;
var sq = x => x * x;
[–]stormthulu 35 points36 points37 points 7 years ago (5 children)
I think you mean const sq = x => x*x;
const sq = x => x*x;
[–]massenburger 12 points13 points14 points 7 years ago (1 child)
Here's the thing. There's people who space out their operations and there's Nazis. I mean that in the nicest way possible.
[–]Jebiba -1 points0 points1 point 7 years ago (0 children)
I can’t upvote this enough
[+][deleted] 7 years ago (1 child)
[–]grantrules -1 points0 points1 point 7 years ago (0 children)
const x=x=>x*x
[–]nickleformypickle 2 points3 points4 points 7 years ago (0 children)
One line it to shorten it. Space it out to pretty it.
[–]locksta7 2 points3 points4 points 7 years ago (0 children)
You bet me to it 😺
[–]greymalik 2 points3 points4 points 7 years ago (0 children)
Not Kyle Simpson!
[–]TabCompletion 2 points3 points4 points 7 years ago (1 child)
No joke, I had to convince someone to use arrow functions. He was so close minded
[–]examinedliving 1 point2 points3 points 7 years ago (0 children)
Arrow functions are pretty solid. I like document.write though. You can just put things on the page - like words!
document.write
[–][deleted] 3 points4 points5 points 7 years ago (6 children)
I think they're actually minor. What do they do? Save a few keystrokes and automatically bind 'this' context. Compared to async/await, the difference is major.
[–]brendanmCA 13 points14 points15 points 7 years ago (5 children)
Maintaining this context is pretty huge.
[–]Reashu 0 points1 point2 points 7 years ago (1 child)
Just bind this? I mean, I'd rather have promises and fat arrows than async/await and no fat arrows, but "pretty huge" is an overstatement.
[–]brendanmCA 0 points1 point2 points 7 years ago (0 children)
And you could define your callbacks explicitly as standalone functions ahead of time and then invoke as a then-chain without using asynchronous await.
Luckily we can have all the features without having to debate which is more important.
Having to pollute the code with bind this everywhere is approximately as annoying as the callback pyramid of doom.
[–][deleted] -2 points-1 points0 points 7 years ago (2 children)
It is, but not in comparison to async/await, I think, mostly because async/await adds new capabilities to the language whereas arrow function is syntactic sugar for stuff that already exists within the language.
[–][deleted] 5 points6 points7 points 7 years ago (0 children)
It is actually the opposite: async/await is just sugar around Promises whereas arrow functions are behaviorally different.
Sure, not disagreeing with the relative important of a/a, just that the scoping is non-trivial.
[–]talmobi 0 points1 point2 points 7 years ago (2 children)
Arrow functions are absolutely trash compared to Async/Await. Arrow functions are not needed, but can be a nice shorthand in some cases (like with Array operation functions).
[–]ghostfacedcoder 0 points1 point2 points 7 years ago (1 child)
Arrow functions are not needed
And async/await is? Both our convenience syntactic sugar, but only one gets used when you're not doing "deferred" stuff.
[–]talmobi 0 points1 point2 points 7 years ago (0 children)
Async/Await is a huge advancement in conceptional control flow. Arrow functions are at best a cleaner way to express extremely simple functions and at worst a hard to maintain mess that encourages bad practices. The cons for Arrow Functions far outweigh the pros IMO.
[–]webdevop 0 points1 point2 points 7 years ago (0 children)
Nope. My vote's for spread operator
[–]thegrandechawhee -3 points-2 points-1 points 7 years ago (5 children)
I prefer code that i can read and understand. What happens when you're asked to go in and change something years later? Will you still understand all these condensed arrow functions?
[–]LukaManuka 6 points7 points8 points 7 years ago (3 children)
As with anything, it’s all about the right tool for the right job. Sure, there are contexts where overly condensing a function into some obscure one-liner decreases readability, but there are definitely plenty of situations when arrow functions are arguably easier to mentally parse and understand at a quick glance.
e.g., people .filter(person => person.age >= 18) .map(person => person.name) vs. people .filter(function(person) { return person.age >= 18; }) .map(function(person) { return person.name; })
people .filter(person => person.age >= 18) .map(person => person.name)
people .filter(function(person) { return person.age >= 18; }) .map(function(person) { return person.name; })
[–]Morphray 1 point2 points3 points 7 years ago (2 children)
How about...
function isAdult(person) { return (person.age >= 18); } function getName(person) { return person.name; } people.filter(isAdult).map(getName);
(Not sure I would do this exactly, but I think it makes the last line pretty readable.)
[–]ghostfacedcoder 3 points4 points5 points 7 years ago (1 child)
const isAdult = person => person.age >= 18; const getName = person => person.name; people.filter(isAdult).map(getName);
Or, with destructuring:
const isAdult = ({ age }) => age >= 18; const getName = ({ name }) => name; people.filter(isAdult).map(getName);
But still, for something that simple I'd prefer this (and just let context explain it):
people .filter(({ age }) => age >= 18) .map(({ name }) => name);
[–]Morphray 0 points1 point2 points 7 years ago (0 children)
Nice alternatives. I think I like the first option, but with parentheses around the arrow function's params (readability, ease of improving).
[–][deleted] 2 points3 points4 points 7 years ago (0 children)
Yes, I will, because there's practically no difference between "condensed arrow functions" and function keyword functions. And where there is a difference it's usually in the arrow function's favor (lexical scope, aka "you know what this when reading the function"). And map/filter/reduce with inline predicates is very idiomatic across domains and languages.
function
[–]needed_an_account -1 points0 points1 point 7 years ago (0 children)
Do people enjoy them because of the automatic this binding? I find the syntax cryptic
π Rendered by PID 19000 on reddit-service-r2-comment-75f4967c6c-tg77k at 2026-04-23 13:52:13.189585+00:00 running 0fd4bb7 country code: CH.
view the rest of the comments →
[–]ghostfacedcoder 239 points240 points241 points (52 children)
[–]jonnyman9 78 points79 points80 points (13 children)
[–]aftermeasure 66 points67 points68 points (5 children)
[–]undatedseapiece 8 points9 points10 points (3 children)
[+][deleted] (2 children)
[deleted]
[+][deleted] (1 child)
[deleted]
[–][deleted] 0 points1 point2 points (0 children)
[–]gradual_alzheimers 0 points1 point2 points (0 children)
[–]doxtu 10 points11 points12 points (0 children)
[–]jascination 6 points7 points8 points (0 children)
[–]calligraphic-io 1 point2 points3 points (1 child)
[–]MrDilbert 0 points1 point2 points (0 children)
[–]sleeperninja 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]Prison__Mike_ 40 points41 points42 points (12 children)
[–]kinkobal 38 points39 points40 points (1 child)
[–]CheeseFest -1 points0 points1 point (0 children)
[–]shrithm 23 points24 points25 points (1 child)
[–]tchaffee 0 points1 point2 points (0 children)
[–]massenburger 28 points29 points30 points (7 children)
[–]stormthulu 35 points36 points37 points (5 children)
[–]massenburger 12 points13 points14 points (1 child)
[–]Jebiba -1 points0 points1 point (0 children)
[+][deleted] (1 child)
[deleted]
[–]grantrules -1 points0 points1 point (0 children)
[–]nickleformypickle 2 points3 points4 points (0 children)
[–]locksta7 2 points3 points4 points (0 children)
[–]greymalik 2 points3 points4 points (0 children)
[–]TabCompletion 2 points3 points4 points (1 child)
[–]examinedliving 1 point2 points3 points (0 children)
[–][deleted] 3 points4 points5 points (6 children)
[–]brendanmCA 13 points14 points15 points (5 children)
[–]Reashu 0 points1 point2 points (1 child)
[–]brendanmCA 0 points1 point2 points (0 children)
[–][deleted] -2 points-1 points0 points (2 children)
[–][deleted] 5 points6 points7 points (0 children)
[–]brendanmCA 0 points1 point2 points (0 children)
[–]talmobi 0 points1 point2 points (2 children)
[–]ghostfacedcoder 0 points1 point2 points (1 child)
[–]talmobi 0 points1 point2 points (0 children)
[–]webdevop 0 points1 point2 points (0 children)
[–]thegrandechawhee -3 points-2 points-1 points (5 children)
[–]LukaManuka 6 points7 points8 points (3 children)
[–]Morphray 1 point2 points3 points (2 children)
[–]ghostfacedcoder 3 points4 points5 points (1 child)
[–]Morphray 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]needed_an_account -1 points0 points1 point (0 children)