I am reading this:
http://blog.carbonfive.com/2013/10/27/the-javascript-event-loop-explained/
There's this quote:
"the single thread of execution asks the runtime to perform an operation, providing a callback 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 message is dequeued and the callback fired."
So an example of what is going on here in my mind is this:
console.log("x")
someAjaxCall(function({
callbackcode
})
console.log("y")
Questions:
1) someAjaxCall is the operation right and callbackcode is the callback?
2) So basically when someAjaxCall is called, a message is enqueued that points to the callbackfunction correct? After console.log("y") is called or when the stack is emptied, the message is dequeued and the callback/callbackcode is fired?
Then there's this quote:
"The decoupling of the caller from the response allows for the JavaScript runtime to do other things while waiting for your asynchronous operation to complete and their callbacks to fire."
3) What is the runtime? What does that mean? I just take it to mean that the callstack can resume execution and when it empties... the messages can then dequeue?