-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAsyncAndAwait.js
More file actions
19 lines (13 loc) · 915 Bytes
/
AsyncAndAwait.js
File metadata and controls
19 lines (13 loc) · 915 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// // Async/await is a programming language feature that allows developers to write asynchronous code in a synchronous manner.
// // "Async" is short for "asynchronous," which refers to code that doesn't block the execution thread.
// Asynchronous code allows other code to continue executing while waiting for a long-running operation,
// such as reading data from a database or making an HTTP request, to complete.
// // "Await" is used to pause the execution of the current method until an asynchronous operation completes.
// This allows the code to wait for the result of the asynchronous operation without blocking the execution thread.
// // Here is an example of using async/await in JavaScript:
async function getData() {
const response = await fetch('https://api.example.com/data');
const data = await response.json();
return data;
}
getData().then(data => console.log(data));