O'Reilly logo

Learning Node, 2nd Edition by Shelley Powers

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. Node Building Blocks: Global Objects, Events, and Node’s Asynchronous Nature

Though both are built on JavaScript, the environments between browser-based applications and Node.js applications are very different. One fundamental difference between Node and its browser-based JavaScript cousin is the buffer for binary data. True, Node does now have access to the ES6 ArrayBuffer and typed arrays. However, most binary data functionality in Node is implemented with the Buffer class.

The buffer is one of Node’s global objects. Another global object is global itself, though the global object in Node is fundamentally different than the global object we’re used to in the browser. Node developers also have access to another global object, process, which provides a bridge between the Node application and its environment.

Thankfully, one aspect of Node should be familiar to frontend developers, and that’s its event-driven asynchronous nature. The difference in Node is that we’re waiting for files to open rather than for users to click a button. 

Event-driven also means those old friends, the timer functions, are available in Node.

Modules and Console

I’ll cover several other global components—require, exports, module, and console— later in the book. I cover the require, exports, and module globals in Chapter 3, and the console in Chapter 4.

The global and process Objects

Two fundamental objects in Node are the global and process objects. The global object is somewhat similar to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required