Browser vs Node.js Runtime
Browser Runtime: // Available in browser window.alert('Hello'); document.getElementById('button'); localStorage.setItem('key', 'value'); fetch('https://api.example.com'); // NOT available in browser const fs = require('fs'); // ERROR! Node.js Runtime: // Available in Node.js const fs = require('fs'); const http = require('http'); process.exit(0); // NOT available in Node.js window.alert('Hello'); // ERROR! document.getElementById('button'); // ERROR! What Does "Providing a Runtime" Mean? When we say "Node.js provides a runtime for JavaScript," we mean: It gives JavaScript a place to run outside the browser It provides access to system resources (files, network, processes) It manages memory and execution It handles errors and crashes It provides utility functions and modules Real-World Example When you run Playwright tests: // Your test file: test.js const { chromium } = requi...