loading...

re: How to Escape Callback Hell with JavaScipt Promises VIEW POST

FULL DISCUSSION
 

Great article! We can condense that even further (no need to write the arguments here)

fightTheDemogorgon()
.then((result) => rollForDamage(result))

Becomes

fightTheDemogorgon()
.then(rollForDamage)

Chaining, aka the Power of Friendship

That's just genius 😂

 

Nice catch!

 

One thing worth noting regarding the shortform though, is that

fightTheDemogorgon()
  .then(rollForDamage)

actually becomes something along the lines of

fightTheDemogorgon()
   .then(function(result) {
   });

rather than

fightTheDemogorgon()
   .then((result) => ...);

which might come with unintended side effects to function scoping and what this actually points to.

Code of Conduct Report abuse