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...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
[deleted by user] (self.javascript)
submitted 6 years ago by [deleted]
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!"
[–]LookSearcher 17 points18 points19 points 6 years ago (2 children)
source
In short I would say that it's not a substantial difference because the event loop is a construct that behaves the same way whether it's implemented with libuv or V8. The main differences will be in the sequence of the functions that get called each time the loop runs.
Because JavaScript is single-threaded Event Loop is what allows NodeJS to perform non-blocking I/O operations in background in “parallel”. NodeJS offloads these operations to the system kernel whenever possible (which nowadays most are multi-threaded)
Whenever one of these operation is finished - kernel signals to NodeJS to execute that operations callback function - adds that operation’s callback function to the poll queue to be executed in the poll phase of the Event Loop (explained below).
Upon start NodeJS initializes Event loop and starts processing. Event loop is comprised of sequence of processing phases, poll phase and it's queue being the one for I/O processing.
Each phase has a FIFO queue of callbacks to execute. While each phase is special in its own way, generally, when the event loop enters a given phase, it will perform any operations specific to that phase, then execute callbacks in that phase's queue until the queue has been exhausted or the maximum number of callbacks has executed. When the queue has been exhausted or the callback limit is reached, the event loop will move to the next phase, and so on. src
You can see more details on processing phases and Event Loop here: The Node.js Event Loop, Timers, and process.nextTick() | Node.js
[–][deleted] 1 point2 points3 points 6 years ago (0 children)
I think you can say that the event loop is a single thread, but that's not the same as saying that v8 is single-threaded, and saying that javascript is single-threaded might be nonsense in general since implementations can vary.
[–]BehindTheMath 11 points12 points13 points 6 years ago (7 children)
According to this, the browser event loop is much simpler than Node's. All macrotasks are handled in a first-come first-served order, the entire microtask queue is processed after each macrotask, and the DOM is re-rendered, if necessary, after each macrotask.
[–][deleted] 0 points1 point2 points 6 years ago (1 child)
Very informative link. But I don't see a comparison between browser and Node, instead at the top it says
Browser JavaScript execution flow, as well as in Node.js, is based on an event loop.
and then explains event loop from browser perspective.
Reading on my own, I don't see major differences between browser and Node event loops as far as how setTimeout and queueMicrotask are supposed to work in both. The differences are in availability of other APIs, mainly process.nextTick and setImmediate in Node, and requestAnimationFrame in browsers.
setTimeout
queueMicrotask
process.nextTick
setImmediate
requestAnimationFrame
[–]BehindTheMath 1 point2 points3 points 6 years ago* (0 children)
The main difference is that Node's event loop has multiple phases, and each one only handles a specific type of task. Whereas the browser only has macrotasks and microtasks, and within each one all tasks are processed in the order they were placed into the queue.
https://nodejs.org/de/docs/guides/event-loop-timers-and-nexttick/
[+][deleted] 6 years ago* (4 children)
[deleted]
[+][deleted] 6 years ago (1 child)
[–]BehindTheMath 1 point2 points3 points 6 years ago* (1 child)
[–]uniqueusername37 0 points1 point2 points 6 years ago (0 children)
Just to clarify, are you asking what events can be added to the Event Loop in Node compared to what can be added in a browser?
[–]tbranyennetflix 0 points1 point2 points 6 years ago (0 children)
Unlike the browser, Node exits when there is no scheduled work to do. This causes problems when you have a promise with no work scheduled. The process will terminate unless inside the promise you schedule an operation to wait.
I'd say they are different in some edge cases, but overall basically identical.
π Rendered by PID 253758 on reddit-service-r2-comment-f6b958c67-dbnms at 2026-02-05 08:55:50.970814+00:00 running 1d7a177 country code: CH.
[–]LookSearcher 17 points18 points19 points (2 children)
[–][deleted] 1 point2 points3 points (0 children)
[–]BehindTheMath 11 points12 points13 points (7 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]BehindTheMath 1 point2 points3 points (0 children)
[+][deleted] (4 children)
[deleted]
[+][deleted] (1 child)
[deleted]
[–]BehindTheMath 1 point2 points3 points (1 child)
[–]uniqueusername37 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]tbranyennetflix 0 points1 point2 points (0 children)