DEV Community

Discussion on: How to Escape Callback Hell with JavaScipt Promises

Collapse
 
molamk profile image
molamk • Edited

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 😂

Collapse
 
amberjones profile image
AmberJ

Nice catch!

Collapse
 
simme profile image
Simme

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.