Chapter 4Node’s Programming Model

A language’s programming model defines how developers write code, and can make or break a language. Since Node is just JavaScript, the rules of the language are the same; however, Node does adhere to a number of additional conventions that make code consistent across its core and third-party modules. In Chapter 2, you learned how to create a simple HTTP server in Node. The goal of this chapter is to help you better understand the code structure of that server so you can extend it to other Node applications.

The Event Loop

The most important concept to understand about JavaScript, and Node by extension, is that it is single-threaded. This means that JavaScript applications can only perform one task at a time. ...

Get Full Stack JavaScript Development With MEAN 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.