Chapter 12. Server-Side JavaScript

The previous chapters have covered the core JavaScript language in detail, and we’re about to start Part II of the book, which explains how JavaScript is embedded in web browsers and covers the sprawling client-side JavaScript API. JavaScript is the programming language of the Web, and most JavaScript code is written for web browsers. But JavaScript is a fast and capable general-purpose language, and there is no reason that JavaScript cannot be used for other programming tasks. So before we transition to client-side JavaScript, we’ll take a quick look at two other JavaScript embeddings. Rhino is a Java-based JavaScript interpreter that gives JavaScript programs access to the entire Java API. Rhino is covered in Scripting Java with Rhino. Node is a version of Google’s V8 JavaScript interpreter with low-level bindings for the POSIX (Unix) API—files, processes, streams, sockets, and so on—and a particular emphasis on asynchronous I/O, networking, and HTTP. Node is covered in Asynchronous I/O with Node.

The title of this chapter says that it is about “server-side” JavaScript, and Node and Rhino are both commonly used to create or to script servers. But the phrase “server-side” can also be taken to mean “anything outside of the web browser.” Rhino programs can create graphical UIs with Java’s Swing framework. And Node can run JavaScript programs that manipulate files the way shell scripts do.

This is a short chapter, intended only to highlight some of ...

Get JavaScript: The Definitive Guide, 6th Edition 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.