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.
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.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
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.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
