Node.js is a runtime environment that lets JavaScript run outside the browser. In the browser, JavaScript handles frontend work like button clicks, animations, and form validation. Node.js, on the other hand, lets JavaScript handle backend work on the server—reading files, connecting to databases, returning API responses, running automation scripts, and more.
// Save this as intro.js
const message = "Node.js runs JavaScript outside the browser.";
const currentYear = new Date().getFullYear();
console.log(message);
console.log(`Learning Node.js in ${currentYear}`);This code saves a string message and prints it out to the terminal using console.log(). Notice that you run it with node intro.js in the Terminal/Command Prompt—not in the browser console.
Node.js runs JavaScript outside the browser. Learning Node.js in 2026Info
new Date() and other built-in JavaScript objects work fine in Node.js too. However, browser-specific objects aren't available.