In this chapter, I’d like to paint the big picture: What are you learning in this book and how does it fit into the overall landscape of web development?

    This book teaches the JavaScript language. It focuses on just the language, but offers occasional glimpses at two platforms where JavaScript can be used:

    • Web browser
    • You can use it to write server-side software in JavaScript.

    • You can also use it to write software for the command line (think Unix shell, Windows PowerShell, etc.). Many JavaScript-related tools are based on (and executed via) Node.js.
    • Node’s software registry, npm, has become the dominant way of installing tools (such as compilers and build tools) and libraries – even for client-side development.

    Figure 2: The structure of the two JavaScript platforms web browser and Node.js. The APIs “standard library” and “platform API” are hosted on top of a foundational layer with a JavaScript engine and a platform-specific “core”.

    The structures of the two JavaScript platforms web browser and Node.js are similar (fig. ):

    • The foundational layer consists of the JavaScript engine and platform-specific “core” functionality.
    • Two APIs are hosted on top of this foundation:
      • The JavaScript standard library is part of JavaScript proper and runs on top of the engine.
      • The platform API are also available from JavaScript – it provides access to platform-specific functionality. For example:
        • In browsers, you need to use the platform-specific API if you want to do anything related to the user interface: react to mouse clicks, play sounds, etc.
        • In Node.js, the platform-specific API lets you read and write files, download data via HTTP, etc.

    You have many options for quickly running pieces of JavaScript. The following subsections describe a few of them.

    5.3.1. Browser consoles

    Web browsers have so-called consoles: Interactive command lines to which you can print text via and where you can run pieces of code. How to open the console differs from browser to browser. Fig. 3 shows the console of Google Chrome.

    To find out how to open the console in your web browser, you can do a web search for “console «name-of-your-browser»”. These are pages for a few commonly used web browsers:

    • Microsoft Edge

    • Figure 3: The console of the web browser “Google Chrome” is open (in the bottom half of window) while visiting a web page.
      Figure 3: The console of the web browser “Google Chrome” is open (in the bottom half of window) while visiting a web page.

    5.3.2. The Node.js REPL

    REPL stands for read-eval-print loop and basically means command line. To use it, you must first start Node.js from an operating system command line, via the command . Then an interaction with it looks as depicted in fig. : The text after is input from the user; everything else is output from Node.js.

    Figure 4: Starting and using the Node.js REPL (interactive command line).

    5.3.3. Other options

    Other options include:

    • There are many web apps that let you experiment with JavaScript in web browsers. For example, .

    When you have a question about a JavaScript, a web search usually helps. I can recommend the following online sources:

    • MDN web docs: cover various web technologies such as CSS, HTML, JavaScript and more. An excellent reference.
    • : contains my JavaScript books.
    • Node.js Docs: document the Node.js API.
    • The chapter at the end of this book, provides a more comprehensive look at web development.