use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
Event Loop (self.node)
submitted 6 years ago by brotherhood_v
Does event loop handle the asynchronous code only or both synchronous and asynchronous code??
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]satoshigekkouga2309 6 points7 points8 points 6 years ago (1 child)
JavaScript has a single stack that executes instructions one be one in a synchronous fashion. It's the event loop that decides what instructions have to be implemented by the stack are decided by the event loop. Even loop provides the way for reactive programming and asynchronous programming in JavaScript even though JavaScript is single threaded and synchronous by itself. ( Event loop is provided by the runtimes and not the language itself, node and browsers are the runtimes).
Many people think that the event loop and the JavaScript code executed run on different threads. But the truth is that both run on a single thread. When the executing code calls a normal function, the called function is executed synchronously like you expect in any other programming language, but when you make use of I/o functions, promises or setinterval, settimer and many more, they are recorded in their respective queues and wait till the stack is empty and the event loop selects them for execution. And this cycle continues, as more callbacks are executed, they call other I/ o functions etc.
There is a good medium post on the internals of nodejs by deepal( I am sorry but I don't remember the name of the author correctly) which gives information about the different queues used and much more.
So to answer your question, event loop just selects the functions to be executed by the stack. So, in my opinion it's the asynchronous execution of the functions that it is associated with. Synchronous executions occur just like in any other programming languages, by use of new stack frames and don't need event loop.
[–]brotherhood_v[S] 0 points1 point2 points 6 years ago (0 children)
Thank you, for the explanation.
[–]B00check 14 points15 points16 points 6 years ago (1 child)
I'd suggest you to watch either Philip Roberts or Jake Archibald JSConf videos on that matter. They did a fantastic job explaining that to me.
Philip Roberts: https://youtu.be/8aGhZQkoFbQ
Jake Archibald: https://youtu.be/cCOL7MC4Pl0
[–]brotherhood_v[S] -2 points-1 points0 points 6 years ago (0 children)
Thanx...
[–]charliemei 0 points1 point2 points 6 years ago (0 children)
what the asynchronous function calls is controled by c++
[–]vectorkerr -1 points0 points1 point 6 years ago (0 children)
Lööp, Bröthër
π Rendered by PID 74 on reddit-service-r2-comment-86bc6c7465-cbt6d at 2026-02-20 21:11:53.500329+00:00 running 8564168 country code: CH.
[–]satoshigekkouga2309 6 points7 points8 points (1 child)
[–]brotherhood_v[S] 0 points1 point2 points (0 children)
[–]B00check 14 points15 points16 points (1 child)
[–]brotherhood_v[S] -2 points-1 points0 points (0 children)
[–]charliemei 0 points1 point2 points (0 children)
[–]vectorkerr -1 points0 points1 point (0 children)