Похожие чаты

Async foo() { const res = await fetch(url); const users = await

res.json();
}
this is synchronous, right??

4 ответов

16 просмотров

in the scope of the function where you are doing this, yes

No. Using await cannot be done outside an async function. Even if you do only sync operations within an async functiom, it is still async

progmatic99- Автор вопроса

It is actually synchronous. I suggest you take a look how the event loop works. In a nutshell, it sees the await keyword and passes that function to another thread, then continues the execution, when the function finishes executing and you have a result it sends a signal for the event loop to be called back to the main thread. Please correct me if I'm wrong

Похожие вопросы

Карта сайта