PGoCareerGoCareer prep tools
LoginSign up
  • Java
  • Python
  • AI
  • React
  • Angular
  • PHP
  • Node.js
  • SQL
  • DSA
  • HTML
  • CSS
  • JS
  • Spring
  • ML
  • MongoDB

Node.js · Theory

Globals

← All stacks

Theory

9/723

Globals

Globals you actually use: console, process, Buffer, setTimeout, __dirname / __filename in CommonJS. In ESM, __dirname is not free — use import.meta.url.

process.env.PORT for config. Don’t dump secrets in source.

Trap — assuming window exists in Node. That’s the browser.

Exam tip

process.env.PORT. No window. __dirname in CommonJS.

Example

// Globals
const users = [
  { id: 1, name: "Asha" },
  { id: 2, name: "Ravi" },
];

function findUser(id) {
  return users.find((u) => u.id === id) ?? null;
}

console.log(findUser(2));
console.log(users.map((u) => u.name));

Globals: find user 2, then list names. Say both prints.

Short notes

  • Defprocess, console, Buffer are Node globals.
  • Ruleprocess.env for config. No window.
  • Trapwindow in Node. __dirname in ESM without a helper.

Questions

1

Is window in Node?

9 / 723

P

GoCareerGo

Utilities · Preparation Hub · Resume · CV · Tools — one workspace.

Workspace

DashboardProfilePreparation HubResume builderCV builderCareer planning

PDF Tools

Merge PDFSplit PDFCompress PDFImage to PDFAll toolsJobs

Image & QR

Compress ImageResize ImageQR ScannerQR GeneratorBlogIT interview prep

Company

FAQFeedbackContactPrivacyTermsSitemap

© 2026 GoCareerGo. Keep moving forward.