Skip to Main Content
Rediscovering JavaScript
book

Rediscovering JavaScript

by Venkat Subramaniam
June 2018
Beginner content levelBeginner
288 pages
6h 31m
English
Pragmatic Bookshelf
Content preview from Rediscovering JavaScript

Ways to Create a Promise

In order to return a promise, asynchronous functions have to first create a promise. If the asynchronous function finds that the task at hand is time consuming, it will internally hold a reference to the promise it creates and return the promise instantaneously to its caller. Once the task is completed, it will pass the result or the error through that promise. However, if the asynchronous function can quickly complete the task at hand, then it can return the promise in the resolved state instead of the pending state, making the result available to the caller right away through the promise. Likewise, if the asynchronous function finds an error in the input parameters given to it, or decides to return an error for any ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Object-Oriented JavaScript - Third Edition

Object-Oriented JavaScript - Third Edition

Stoyan STEFANOV, Ved Antani
Deno Web Development

Deno Web Development

Alexandre Portela dos Santos

Publisher Resources

ISBN: 9781680506174Errata Page