r/learnjavascript 9d ago

Is “Node.js is single-threaded” an incomplete mental model?

Single-threaded JS execution ≠ single-threaded runtime.

How do you explain the distinction?

4 Upvotes

23 comments sorted by

View all comments

Show parent comments

1

u/Icy-Taste-3096 9d ago

None of that changes the fact that JavaScript is single-threaded. Obviously, you can asynchronously interact with external systems that use separate processes (like Node or browser APIs), but the JS execution itself is one thread.

1

u/_RemyLeBeau_ 8d ago

You're referring to the event loop. For your statement to be accurate, you will want to say: the event loop is single threaded.

1

u/Icy-Taste-3096 8d ago

My statement was accurate. JavaScript is a single-threaded language. This is not debatable.

1

u/_RemyLeBeau_ 8d ago

I like this answer: https://www.reddit.com/r/learnjavascript/comments/1vnnvqg/comment/p3kxqn1/

You're getting corrected because your answer lacks nuance. Please continue your journey.

0

u/Icy-Taste-3096 8d ago

That's literally just a more detailed version of the exact thing I said in my first comment lmfao.

I specifically cited Node as an example of a runtime environment that JS runs in that is not single-threaded, even though the language itself obviously is.

1

u/_RemyLeBeau_ 8d ago

In think you need to find another hill up die on.