News for hackers. Stuff that matters.
Re:I Avoid Async/Await by kabes on Saturday April 16, 2022 @12:05PM (#31053399)
I agree but second one could just be `() => Promise.resolve()`
Re:I Avoid Async/Await by adamauckland on Saturday April 16, 2022 @12:24PM (#31053618)
It could, but depending on how you use it, you're changing scoping.
Re:I Avoid Async/Await by kabes on Saturday April 16, 2022 @05:42PM (#31056347)
True. But these days it's rare to see a scope other than what you'd expect from the short hand version. Old school JS with plain prototypes and flexible 'this' scope is very powerful, but is too hard to understand and thus rare these days.
Re:I Avoid Async/Await by eurasiantiger on Sunday April 17, 2022 @11:08AM (#31061365)
That’s one of the neat things about JS: even outside the prototypal inheritance chain, classes can be (partially) composed of generalized, reusable functions, a bit like traits. Just import a function and bind it in the constructor (call).