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

Asked

Viewed 60 times

2

Checking the app built by Philip Roberts( http://latentflip.com/loupe ) that demonstrates the functioning of the web browser loop Event and webapi, I noticed that only when we use callbacks calling methods like setTimeout..., there is manifestation of the webapi to consider this call as asynchronous.

How can I know which methods are executed asynchronously then?

1 answer

3


Which methods are executed asynchronously?

Beyond the setTimeout that you mentioned there is the setInterval, calls ajax/xhr, Promises, async/await and all past functions to event headphones.

In practice, knowing which asynchronous functions in general is difficult, those who write them should be aware that they are using them.

But it can be generally said that functions that wait for something to happen are asynchronous. Be a timer (setTimeout/setInterval), an ajax to an external server, or waiting for an event that will be triggered.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.