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

Node.js · Theory

First Example

← All stacks

Theory

4/723

First Example

console.log('Hello Node'); save as hello.js; run node hello.js. That is first example. Then a tiny server: require('http') or import, listen on 3000, res.end('Hello').

If node is not recognised, Node isn’t installed or PATH is old — open a new terminal.

Trap — writing <script> in a .js file you run with node. That’s browser HTML.

Exam tip

console.log('Hello Node'); node hello.js

Example

// First Example
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));

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

Short notes

  • Defnode hello.js prints Hello.
  • RuleNew terminal after install.
  • TrapBrowser HTML inside Node files.

Questions

1

First Node command?

4 / 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.