Working with JavaScript in Node.js
Learn how Node.js replaces the browser's window with a global object to access properties and functions like console and setTimeout. Understand using global scope, practice asynchronous timing functions, and experiment within the Node.js REPL for practical JavaScript coding outside the browser.
When using JavaScript in the browser, we work with the window object as the global scope, which includes methods like alert() and properties like location. However, in Node.js, there is no window object because it operates outside the browser environment. Instead, Node.js uses its own global object, global, to store globally accessible properties and functions. Functions like console.log() and setTimeout() are part of this global scope and can be used directly in Node.js applications.
While we can reference properties on the global object explicitly, in most cases, we can access global properties directly without needing the global. prefix.
Common global properties and functions
Here are a ...