(Ad, please don’t block.)
5. The big picture
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?
5.1. What are you learning in this book?
- Web browsers
Node.js is important for web development in three ways:
- Node’s package manager, npm, has become the dominant way of installing tools (such as compilers and build tools) and libraries – even for client-side development.
5.2. The structure of browsers and Node.js
- In browsers, you need to use platform-specific APIs if you want to do anything related to the user interface: react to mouse clicks, play sound, etc.
- In Node.js, platform-specific APIs let you read and write files, download data via HTTP, etc.
5.2.1. The console
console.log('This text is shown on the “console”!');
- On browsers, the console is a pane with text that is usually hidden, but can be brought up.
- On Node.js, anything you log to the console is printed on the command line (think stdout).
5.3.1. Browser consoles
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 some commonly used web browsers:
Figure 3: The console of the web browser “Google Chrome” is open 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 node. Then an interaction with it looks as depicted in fig. 4: 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).
Reading: REPL interactions
> 3 + 5 8
5.3.3. Other options
Other options include:
5.4. Further reading
- The chapter “Next steps” at the end of this book, provides a more comprehensive look at web development.
Next: 6. Syntax