JavaScript in Node.js
One important consequence of the architecture we have just analyzed is that the JavaScript we use in Node.js is somewhat different from the JavaScript we use in the browser.
The major difference between running JavaScript in the browser (client-side) and in Node.js (server-side) lies in their execution environments. In the browser, JavaScript runs when a user visits a web page, requiring a secure environment to prevent unrestricted access to the user’s system and potential vulnerabilities. On the server side, however, we have more control and typically need access to databases, the filesystem, the network, and other system resources to build functional applications. As a result, Node.js has access to all the services provided by the operating system.
Although both Node.js and the browser can execute JavaScript, their different use cases and security requirements lead to significantly different APIs. The most important difference is that, in Node...