Useful Links
Computer Science
Programming
By Language
Asynchronous JavaScript
1. Foundations of Asynchronous JavaScript
2. Legacy Asynchronous Patterns: Callbacks
3. The Promise API
4. Async/Await Syntax
5. Common Asynchronous Web APIs
6. Advanced Asynchronous Patterns and Concepts
The Promise API
Introduction to Promises
Definition and Purpose
A Placeholder for a Future Value
Solving Callback Hell
Flattening Asynchronous Code
Improved Error Handling
Promise States
Pending
Initial State
Characteristics and Behavior
Fulfilled
Successful Completion
Value Resolution
Rejected
Failure or Error Occurred
Reason for Rejection
State Transitions
Immutability of Settled Promises
Creating Promises
The Promise Constructor
Syntax and Usage
Executor Function
Synchronous Execution
Parameters: resolve and reject
The resolve Function
Resolving with a Value
Resolving with Another Promise
Thenable Objects
The reject Function
Rejecting with an Error
Rejecting with Any Value
Consuming Promises
The then Method for Success
Chaining Success Handlers
Returning Values from then
Transformation of Values
The catch Method for Errors
Handling Rejections
Chaining Error Handlers
Error Recovery
The finally Method for Cleanup
Executing Cleanup Logic
Behavior with Fulfillment and Rejection
Value Pass-Through
Chaining Promises
Returning Values from then
Passing Results to Next Handler
Value Transformation
Returning Promises from then
Flattening Nested Promises
Avoiding Callback Hell in Promises
Handling Multiple Asynchronous Steps
Sequential Operations
Data Flow Through Chain
Error Handling in Promise Chains
Propagating Errors
Automatic Propagation Down the Chain
Skipping then Handlers
Centralized Error Handling with catch
Catching Errors from Any Step
Error Recovery Strategies
Unhandled Promise Rejections
Detection and Warnings
Global Handlers
unhandledrejection Event
rejectionhandled Event
Static Promise Methods
Promise.all
Handling Multiple Concurrent Promises
Aggregating Results
Fail-Fast Behavior
Input Types and Validation
Promise.allSettled
Waiting for All Promises to Settle
Inspecting Outcomes
Fulfilled Results
Rejected Results
Use Cases for Resilient Operations
Promise.race
Getting the First Settled Promise
Use Cases and Limitations
Timeout Implementations
Promise.any
Getting the First Fulfilled Promise
Handling All Rejections
AggregateError
Promise.resolve
Creating a Resolved Promise
Wrapping Non-Promise Values
Thenable Conversion
Promise.reject
Creating a Rejected Promise
Use Cases in Testing and Error Simulation
Previous
2. Legacy Asynchronous Patterns: Callbacks
Go to top
Next
4. Async/Await Syntax