CHAPTER 3

image

The Node Programming Model

Before trying to write any meaningful Node applications, it’s important to understand what’s going on under the hood. Probably the most important thing to understand is that JavaScript—and Node by extension—is single threaded. This means that Node applications can do exactly one thing at a time. However, JavaScript can give the illusion of being multithreaded through the use of an event loop. The event loop is used to schedule tasks in Node’s event-driven programming model. Each time an event occurs, it is placed in Node’s event queue. In each iteration of the event loop, a single event is dequeued and processed. ...

Get Pro Node.js for Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.