What is javascript asychronous programming and event loop?

Here are the notes about how I learn the concepts of javascript asynchronous programming and event loop from different online resources. Please note that the last resource is REALLY good.

_____________

http://2014.jsconf.eu/speakers/philip-roberts-what-the-heck-is-the-event-loop-anyway.html

– brower is powered by Google V8 engine
– have call stack basically recall where we are in the program
– single thread ( it can only do one thing at a time)

– if there are too many components on the stack, then what if one thing is slow?
– we just wait one thing to be done and then another thing?….but we are doing in browser, if then the user has to keep waiting.

How to handle this?
-asynchronous callbacks
Note: Stack is where your steps being processed. There a task queue to handle callback as well.

_______________________________________________________________-
http://blog.carbonfive.com/2013/10/27/the-javascript-event-loop-explained/

-In javascript, almost all I/O is non-blocking, meaning that the single thread of execution asks the runtim to perform an operation, providing a callbuck function and then moves on to do something else.
– WHen the operation has been completed, a message is enqueued along with the provided callback function. At some point in the future, the meesage is dequeued and the callback fired.

Read more: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/EventLoop

________________________________________________________
http://javascript.info/tutorial/events-and-timing-depth

– Most events in javascript are asynchronous
– WHen an asynchronous event occurs, it gets into the event queue.
– The browser has inner loop, called event loop, which checks the queue and processess events, executes function

__________________________________________________________
http://www.altitudelabs.com/blog/what-is-the-javascript-event-loop/

(Great explanation)

-WHen there is a callback, it will be placed in to event table and then later move to event queue (after it is completed) . There is a process constantly checking if the call stack is empty, if so then it will checks if the event queue has any functions waiting to be invoked, if it does, then the first function will be invoked and moved over to the call stack. <– this is event loop