Introduction — Node.js Technical Interview Questions & Answers
Introduction
Introduction
- Node.js runs JavaScript on the server (and in scripts), not only in the browser. Chrome’s V8 engine + an event loop. You write hello.js, run node hello.js, and it prints. No Apache required for a tiny API.
- It is not a new language. It is JavaScript plus modules like fs, http, path. npm installs extra packages. Good for APIs, tooling, realtime chat. CPU-heavy number crunching can block the event loop — offload it.
- Trap: ‘Node is a language’. Trap: ‘Node replaces the browser’. The browser still runs JS for pages. Node runs JS on the machine.
hello.js
│ node
▼
V8 + event loop
│
▼
console / HTTPTechnical Interview Tip: JS on the server. node hello.js. Not a new language.
Code Examples for Introduction
Introduction — working example
// Introduction
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));Introduction: find user 2, then list names. Say both prints.
How to Explain Introduction to an Interviewer
What is Node.js?
JavaScript runtime outside the browser node file.js
Why event loop?
Non-blocking I/O for APIs Don’t block it with heavy CPU