Are callback functions asynchronous, only with specific methods like setTimeout?

2

Checking the app built by Philip Roberts ( link ) that demonstrates how the browser and webapi event loop works, I noticed that only when we use callbacks calling methods like setTimeout ..., there is manifestation of webapi to consider this call as asynchronous.

How can I know which methods execute asynchronously then?

    
asked by anonymous 09.04.2017 / 04:34

1 answer

3
  

What methods are executed asynchronously?

In addition to the% with% you mentioned there is setTimeout , calls setInterval / ajax , xhr , Promises / async and all functions passed to event headers. >

In practice, to know which asynchronous functions are generally difficult, whoever writes them should be aware that they are using them.

But it can be said in general that functions waiting for something to happen are asynchronous. Whether it is a timer ( await / setTimeout ), an ajax to an external server, or waiting for an event to be triggered.

    
09.04.2017 / 05:18