async/await (EN)

Programming Language

JavaScript syntax to simplify asynchronous programming with Promises

Architecture

You use async/await in JavaScript to write asynchronous code in a synchronous-looking syntax and improve readability. The 'async' keyword before a function declares it as asynchronous and enables the use of 'await' within the function. With 'await', you can wait for the result of a Promise without blocking the Event Loop, bringing the code into a linear, easily understandable structure. This syntax significantly simplifies handling asynchronous operations compared to nested callbacks or long Promise chains and makes error handling with try/catch blocks more intuitive.

sequenceDiagram     participant Client     participant Server     participant Database          Client->>Server: Datenanfrage     activate Server     Server->>Database: Datenabfrage     activate Database     Database-->>Server: Daten     deactivate Database     Server-->>Client: Antwort     deactivate Server 
Quelle: AI Generated