DOM Manipulation in JavaScript
15 questions · 12 min · Medium
Test your knowledge of asynchronous JavaScript and Promises with 15 questions covering callbacks, Promises, Promise states, then, catch, finally, chaining, and Promise combinators.
No sign-up needed · Last updated:
Score: 0 00:00
Create a free account to keep your scores and track your progress. It is optional.
15 questions · 12 min · Medium
15 questions · 12 min · Medium
20 questions · 15 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
15 questions · 12 min · Medium
B. Perform operations without blocking the continuation of other work
Asynchronous programming allows JavaScript to start an operation and continue handling other work while waiting for the asynchronous operation to complete.
A. Promises
Promises provide a standard way to represent the eventual completion or failure of an asynchronous operation.
B. Pending, Fulfilled, Rejected
A Promise starts in the pending state and eventually becomes either fulfilled or rejected.
B. then()
The then() method registers handlers that can be executed when a Promise is fulfilled.
A. catch()
The catch() method registers a rejection handler for a Promise chain.
B. finally()
Promise.prototype.finally() runs a callback after the Promise settles, whether it is fulfilled or rejected.
A. new Promise()
A Promise can be created using the Promise constructor, such as new Promise((resolve, reject) => { ... }).
B. resolve and reject
The executor function passed to a Promise constructor receives resolve and reject functions that settle the Promise as fulfilled or rejected.
A. Its fulfillment value becomes available to handlers such as then()
When a Promise is fulfilled, its resulting value can be received by fulfillment handlers registered with then().
B. Its rejection reason can be handled by catch()
A rejected Promise contains a rejection reason that can be handled using catch() or an appropriate rejection handler.
B. Linking multiple asynchronous operations using successive then() calls
Promise chaining allows the result of one asynchronous operation to be passed into the next operation through successive then() calls.
A. Promise.all()
Promise.all() fulfills when all input Promises fulfill and provides their fulfillment values in an array. It rejects when an input Promise rejects.
B. Settles with the first input Promise that settles
Promise.race() settles as soon as the first input Promise settles, whether that Promise fulfills or rejects.
A. A function passed to another function to be called later
A callback is a function supplied to another function so it can be invoked later, commonly after an asynchronous operation completes.
A. Promises provide a structured abstraction for representing asynchronous results and can reduce deeply nested callback code
Promises provide a structured way to represent eventual success or failure and support chaining, which can make complex asynchronous workflows easier to manage.