YDKNJS async Flashcards
is it possible to handle ajax synchoronasly?
yes but it will block the user from interacting with the page
what is the simplest way to handle ajax?
using a callback
is a callback synchronous or asynchronous?
asynchronous
what is a callback function?
it a functions registered in the event loop to run after a task is done like ajax network request
is the event loop a stack or a queue?
a queue
does setTimeout insert function in event loop?
no it sets up a timer and after the timer is finished the function gets inserted into the loop
what happens if you have multiple callbacks in eventloop?
they get executed synchronously one by one
what is the difference between parallel and async?
async : time between now and later
parallel: things executing simultaneously
is js async multi thread or single thread?
single thread meaning that data is not shared between threads
what is concurrency?
it’s when two processes execute simultaneously over the same period of time
what is a race condition bug?
it’s a bug that occurs when we don’t know whether response 1 or response 2 will come back first with async requests
what is a tick in event loop?
it’s an iteration of the event loop
what is a job queue?
it’s a queue that happens after each tick that adds new jobs to the queue immediately after an async item is ran
can a job add another job to the event loop?
yes
can u predict the ordering of async?
no you cannot