Can You Spot the Subtle Differences in These Four Promise Patterns?

While most JavaScript developers are familiar with using Promises, many overlook subtle nuances; this article presents four Promise snippets, challenges you to identify their differences, and invites curious programmers to explore further, even mentioning an upcoming Node.js meetup in Guangzhou.

Node Underground
Node Underground
Node Underground
Can You Spot the Subtle Differences in These Four Promise Patterns?

At the end of 2016, almost every JavaScript developer had already learned to use Promises in daily development.

However, not everyone truly understands some details of Promises. Below are four Promise use cases—can you tell the differences?

doSomething().then(v => doSomethingElse(v)).then(finalHandler);

doSomething().then(function(v) {
  doSomethingElse(v);
}).then(finalHandler);

doSomething().then(doSomethingElse()).then(finalHandler);

doSomething().then(doSomethingElse).then(finalHandler);

I bet fewer than half can point out the exact distinctions.

Only curious programmers make progress, so if you’re reading this on your phone, are you eager to click “Read the original article” to find out?

Also, remember the Node.js underground rail salon on December 3 at Guangzhou Guangdian Pingyun Plaza? Don’t miss it. If you’re worried about directions, just open http://nodejs.club to view the map.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Node.jsAsync
Node Underground
Written by

Node Underground

No language is immortal—Node.js isn’t either—but thoughtful reflection is priceless. This underground community for Node.js enthusiasts was started by Taobao’s Front‑End Team (FED) to share our original insights and viewpoints from working with Node.js. Follow us. BTW, we’re hiring.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.