{"id":195,"date":"2026-10-12T13:39:03","date_gmt":"2026-10-12T13:39:03","guid":{"rendered":"https:\/\/devdojo.co.in\/?p=195"},"modified":"2026-10-12T13:39:03","modified_gmt":"2026-10-12T13:39:03","slug":"nodejs-interview-questions","status":"publish","type":"post","link":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/","title":{"rendered":"Node.js Interview Questions and Answers: Event Loop, Async and More"},"content":{"rendered":"\n<div class=\"dd-post\">\n<style>\n.single article:has(.dd-hero) .entry-media{display:none}\n.dd-post{--dd-navy:#0b1020;--dd-blue:#3178c6;--dd-violet:#7c5cff;--dd-ink:#1d2333;--dd-muted:#5b6478;--dd-line:#e3e7f0;--dd-soft:#f5f7fc;line-height:1.75;color:var(--dd-ink)}\n.dd-post h2{margin:2.2em 0 .6em;font-size:1.7em;line-height:1.3;scroll-margin-top:90px}\n.dd-post h3{margin:1.6em 0 .5em;font-size:1.25em;line-height:1.35;scroll-margin-top:90px}\n.dd-post p{margin:0 0 1.1em}\n.dd-post a{color:var(--dd-blue);text-decoration:underline;text-underline-offset:3px}\n.dd-post .dd-hero{margin:0 0 1.6em;border-radius:16px;overflow:hidden;box-shadow:0 12px 40px rgba(11,16,32,.35)}\n.dd-post .dd-hero svg{display:block;width:100%;height:auto}\n.dd-post .dd-hero .hn rect{transition:fill .25s,stroke .25s}\n.dd-post .dd-hero .hn:hover rect{fill:#3178c6;stroke:#a99bff}\n.dd-post .dd-hero .hn{cursor:default}\n.dd-post pre{background:#0f1430;color:#e6e9f5;padding:18px 20px;border-radius:12px;overflow-x:auto;margin:0 0 1.4em;border:1px solid #232a52;line-height:1.6;font-size:14.5px !important}\n.dd-post pre code{font-family:\"JetBrains Mono\",\"Fira Code\",Consolas,Menlo,monospace;font-size:1em !important;background:none;color:inherit;padding:0;white-space:pre}\n.dd-post :not(pre)>code{background:#eef1fb;color:#3a2fa8;padding:2px 6px;border-radius:5px;font-size:.92em}\n.dd-post .dd-file{display:inline-block;background:#232a52;color:#c9d1ff;font:600 12.5px\/1 Consolas,monospace;padding:6px 10px;border-radius:8px 8px 0 0;margin:0}\n.dd-post .dd-file+pre{border-top-left-radius:0;margin-top:0}\n.dd-post .dd-summary{background:linear-gradient(135deg,#eef3ff,#f3efff);border:1px solid #d6dcfb;border-left:5px solid var(--dd-violet);border-radius:12px;padding:18px 22px;margin:0 0 1.6em}\n.dd-post .dd-summary strong.lbl{display:block;font-size:1.05em;margin-bottom:6px;color:#3a2fa8}\n.dd-post .dd-summary ul{margin:0;padding-left:1.2em}\n.dd-post .dd-toc{background:var(--dd-soft);border:1px solid var(--dd-line);border-radius:12px;padding:16px 22px;margin:0 0 1.8em}\n.dd-post .dd-toc ol{margin:.4em 0 0;padding-left:1.3em;columns:2;column-gap:28px}\n.dd-post .dd-toc li{margin:.2em 0;break-inside:avoid}\n.dd-post .dd-tip,.dd-post .dd-note,.dd-post .dd-warn{border-radius:10px;padding:14px 18px;margin:0 0 1.4em}\n.dd-post .dd-tip{background:#ecfbf3;border-left:4px solid #1f9d61}\n.dd-post .dd-note{background:#eef4ff;border-left:4px solid var(--dd-blue)}\n.dd-post .dd-warn{background:#fff6e8;border-left:4px solid #e08a00}\n.dd-post .dd-q{background:#fff;border:1px solid var(--dd-line);border-radius:12px;padding:16px 20px;margin:0 0 1.2em;box-shadow:0 2px 10px rgba(20,30,70,.05)}\n.dd-post .dd-q h3{margin-top:0}\n.dd-post .dd-q .tag{display:inline-block;font-size:12px;font-weight:700;letter-spacing:.03em;padding:3px 9px;border-radius:20px;margin-left:6px;vertical-align:middle}\n.dd-post .t-b{background:#e5f6ec;color:#16784a}.dd-post .t-i{background:#e8efff;color:#2459a8}.dd-post .t-a{background:#efe9ff;color:#5a3cc7}\n.dd-post table{width:100%;border-collapse:collapse;margin:0 0 1.6em;font-size:.95em}\n.dd-post th{background:#151b3b;color:#fff;text-align:left;padding:10px 12px}\n.dd-post td{border-bottom:1px solid var(--dd-line);padding:10px 12px;vertical-align:top}\n.dd-post tr:nth-child(even) td{background:#f8f9fd}\n.dd-post .dd-tablewrap{overflow-x:auto}\n.dd-post figure{margin:0 0 1.8em;text-align:center}\n.dd-post figure svg{width:100%;height:auto;border-radius:14px;display:block}\n.dd-post figcaption{font-size:.9em;color:var(--dd-muted);margin-top:8px}\n.dd-post details{border:1px solid var(--dd-line);border-radius:10px;padding:12px 16px;margin:0 0 .8em;background:#fff}\n.dd-post details summary{cursor:pointer;font-weight:700}\n.dd-post details[open] summary{margin-bottom:8px;color:#3a2fa8}\n.dd-post .dd-explorer{border:1px solid #232a52;border-radius:14px;background:#0f1430;color:#e6e9f5;padding:18px;margin:0 0 1.8em}\n.dd-post .dd-explorer input{position:absolute;opacity:0;pointer-events:none}\n.dd-post .dd-explorer .tabs{display:flex;flex-wrap:wrap;gap:8px;margin-bottom:14px}\n.dd-post .dd-explorer label{cursor:pointer;padding:8px 14px;border-radius:999px;background:#1b2250;color:#c9d1ff;font-weight:600;font-size:.92em;border:1px solid #2e3770;transition:background .2s}\n.dd-post .dd-explorer label:hover{background:#26307a}\n.dd-post .dd-explorer .panel{display:none;background:#151b3b;border-radius:10px;padding:14px 18px;line-height:1.7}\n.dd-post .dd-explorer .panel b{color:#a99bff}\n.dd-post .dd-explorer .panel code{background:#232a52;color:#ffd479;padding:1px 6px;border-radius:5px}\n#ddp1:checked~.tabs label[for=ddp1],#ddp2:checked~.tabs label[for=ddp2],#ddp3:checked~.tabs label[for=ddp3],#ddp4:checked~.tabs label[for=ddp4],#ddp5:checked~.tabs label[for=ddp5],#ddp6:checked~.tabs label[for=ddp6]{background:linear-gradient(135deg,#3178c6,#7c5cff);color:#fff;border-color:transparent}\n#ddp1:checked~.panels .p1,#ddp2:checked~.panels .p2,#ddp3:checked~.panels .p3,#ddp4:checked~.panels .p4,#ddp5:checked~.panels .p5,#ddp6:checked~.panels .p6{display:block}\n.dd-post .dd-cta{background:linear-gradient(135deg,#0b1020,#151b3b);color:#e6e9f5;border-radius:16px;padding:26px 28px;margin:2em 0 1em;border:1px solid #2e3770}\n.dd-post .dd-cta h3{color:#fff;margin:0 0 .4em}\n.dd-post .dd-cta a{color:#a99bff}\n@media (max-width:640px){.dd-post .dd-toc ol{columns:1}.dd-post pre{padding:14px}}\n<\/style>\n\n<div class=\"dd-hero\">\n<svg viewBox=\"0 0 1200 520\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" role=\"img\" aria-labelledby=\"ddHeroTitle ddHeroDesc\">\n<title id=\"ddHeroTitle\">Node.js Interview Questions<\/title>\n<desc id=\"ddHeroDesc\">Banner showing the Node.js event loop connected to topics: async code, streams, worker threads and modern Node features.<\/desc>\n<defs>\n<linearGradient id=\"ddhbg\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"1\"><stop offset=\"0\" stop-color=\"#0b1020\"\/><stop offset=\"1\" stop-color=\"#151b3b\"\/><\/linearGradient>\n<linearGradient id=\"ddhac\" x1=\"0\" y1=\"0\" x2=\"1\" y2=\"0\"><stop offset=\"0\" stop-color=\"#3178c6\"\/><stop offset=\"1\" stop-color=\"#7c5cff\"\/><\/linearGradient>\n<radialGradient id=\"ddhglow\" cx=\"0.5\" cy=\"0.5\" r=\"0.5\"><stop offset=\"0\" stop-color=\"#7c5cff\" stop-opacity=\".45\"\/><stop offset=\"1\" stop-color=\"#7c5cff\" stop-opacity=\"0\"\/><\/radialGradient>\n<\/defs>\n<rect class=\"bgx\" x=\"0\" y=\"0\" width=\"1200\" height=\"520\" fill=\"url(#ddhbg)\"\/>\n<g opacity=\".18\" stroke=\"#3b4580\" stroke-width=\"1\">\n<path d=\"M0 104H1200M0 208H1200M0 312H1200M0 416H1200\"\/>\n<path d=\"M150 0V520M300 0V520M450 0V520M600 0V520M750 0V520M900 0V520M1050 0V520\"\/>\n<\/g>\n<circle cx=\"905\" cy=\"270\" r=\"220\" fill=\"url(#ddhglow)\"\/>\n<text x=\"70\" y=\"150\" fill=\"#a99bff\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"22\" font-weight=\"700\" letter-spacing=\"4\">DEVDOJO \u00b7 CAREER PREP<\/text>\n<text x=\"70\" y=\"222\" fill=\"#ffffff\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"60\" font-weight=\"800\">Node.js Interview<\/text>\n<text x=\"70\" y=\"292\" fill=\"#ffffff\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"60\" font-weight=\"800\">Questions<\/text>\n<rect x=\"70\" y=\"316\" width=\"210\" height=\"6\" rx=\"3\" fill=\"url(#ddhac)\"\/>\n<text x=\"70\" y=\"366\" fill=\"#c9d1ff\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"24\">Event loop, async code, streams and scaling \u2014<\/text>\n<text x=\"70\" y=\"400\" fill=\"#c9d1ff\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"24\">explained simply, with runnable answers<\/text>\n<g fill=\"none\" stroke=\"#3b4a8f\" stroke-width=\"2\">\n<path id=\"ddhp1\" d=\"M905 270 L760 140\"\/><path id=\"ddhp2\" d=\"M905 270 L1060 140\"\/><path id=\"ddhp3\" d=\"M905 270 L760 400\"\/><path id=\"ddhp4\" d=\"M905 270 L1060 400\"\/>\n<\/g>\n<circle cx=\"905\" cy=\"270\" r=\"62\" fill=\"#151b3b\" stroke=\"url(#ddhac)\" stroke-width=\"4\"\/>\n<circle cx=\"905\" cy=\"270\" r=\"78\" fill=\"none\" stroke=\"#7c5cff\" stroke-opacity=\".5\" stroke-width=\"2\" stroke-dasharray=\"6 10\"><animateTransform attributeName=\"transform\" type=\"rotate\" from=\"0 905 270\" to=\"360 905 270\" dur=\"18s\" repeatCount=\"indefinite\"\/><\/circle>\n<text x=\"905\" y=\"264\" text-anchor=\"middle\" fill=\"#fff\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"19\" font-weight=\"700\">Event<\/text>\n<text x=\"905\" y=\"288\" text-anchor=\"middle\" fill=\"#fff\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"19\" font-weight=\"700\">Loop<\/text>\n<g class=\"hn\"><rect x=\"690\" y=\"112\" width=\"140\" height=\"52\" rx=\"12\" fill=\"#1b2250\" stroke=\"#3178c6\" stroke-width=\"2\"\/><text x=\"760\" y=\"144\" text-anchor=\"middle\" fill=\"#e6e9f5\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"18\" font-weight=\"600\">async\/await<\/text><\/g>\n<g class=\"hn\"><rect x=\"990\" y=\"112\" width=\"140\" height=\"52\" rx=\"12\" fill=\"#1b2250\" stroke=\"#3178c6\" stroke-width=\"2\"\/><text x=\"1060\" y=\"144\" text-anchor=\"middle\" fill=\"#e6e9f5\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"18\" font-weight=\"600\">Streams<\/text><\/g>\n<g class=\"hn\"><rect x=\"690\" y=\"374\" width=\"140\" height=\"52\" rx=\"12\" fill=\"#1b2250\" stroke=\"#3178c6\" stroke-width=\"2\"\/><text x=\"760\" y=\"406\" text-anchor=\"middle\" fill=\"#e6e9f5\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"18\" font-weight=\"600\">Workers<\/text><\/g>\n<g class=\"hn\"><rect x=\"990\" y=\"374\" width=\"140\" height=\"52\" rx=\"12\" fill=\"#1b2250\" stroke=\"#3178c6\" stroke-width=\"2\"\/><text x=\"1060\" y=\"406\" text-anchor=\"middle\" fill=\"#e6e9f5\" font-family=\"Segoe UI,Arial,sans-serif\" font-size=\"18\" font-weight=\"600\">Modern Node<\/text><\/g>\n<circle r=\"6\" fill=\"#7c5cff\"><animateMotion dur=\"2.6s\" repeatCount=\"indefinite\"><mpath href=\"#ddhp1\"\/><\/animateMotion><\/circle>\n<circle r=\"6\" fill=\"#3178c6\"><animateMotion dur=\"3.1s\" repeatCount=\"indefinite\"><mpath href=\"#ddhp2\"\/><\/animateMotion><\/circle>\n<circle r=\"6\" fill=\"#a99bff\"><animateMotion dur=\"2.9s\" repeatCount=\"indefinite\"><mpath href=\"#ddhp3\"\/><\/animateMotion><\/circle>\n<circle r=\"6\" fill=\"#5aa2f0\"><animateMotion dur=\"3.4s\" repeatCount=\"indefinite\"><mpath href=\"#ddhp4\"\/><\/animateMotion><\/circle>\n<\/svg>\n<\/div>\n\n<div class=\"dd-summary\">\n<strong class=\"lbl\">Quick Summary<\/strong>\n<ul>\n<li>This guide covers the <strong>Node.js interview questions<\/strong> that come up most often for junior and mid-level backend roles, with short answers you can say out loud.<\/li>\n<li>The big topics are the <strong>event loop<\/strong>, <strong>async code<\/strong> (callbacks, promises, async\/await), <strong>streams<\/strong>, and <strong>scaling<\/strong> (cluster vs worker threads).<\/li>\n<li>Every answer comes with a small, runnable code example. Run them with Node.js 24 or 26.<\/li>\n<li>Interviewers now also ask about modern built-in features: <code>fetch<\/code>, the test runner, <code>--watch<\/code>, <code>--env-file<\/code> and running TypeScript directly.<\/li>\n<\/ul>\n<\/div>\n\n<nav class=\"dd-toc\" aria-label=\"Table of contents\">\n<strong>In this guide<\/strong>\n<ol>\n<li><a href=\"#how-to-use\">How to use this guide<\/a><\/li>\n<li><a href=\"#basics\">Node.js basics questions<\/a><\/li>\n<li><a href=\"#event-loop\">Event loop questions<\/a><\/li>\n<li><a href=\"#async\">Async code questions<\/a><\/li>\n<li><a href=\"#streams\">Streams and buffers<\/a><\/li>\n<li><a href=\"#scaling\">Scaling and performance<\/a><\/li>\n<li><a href=\"#modern-node\">Modern Node.js features<\/a><\/li>\n<li><a href=\"#express-api\">API and Express questions<\/a><\/li>\n<li><a href=\"#mistakes\">Common mistakes and fixes<\/a><\/li>\n<li><a href=\"#tips\">Interview tips<\/a><\/li>\n<li><a href=\"#faq\">FAQ<\/a><\/li>\n<li><a href=\"#conclusion\">Conclusion<\/a><\/li>\n<\/ol>\n<\/nav>\n\n<p>If you are preparing for a backend or full-stack job, you will almost certainly face <strong>Node.js interview questions<\/strong>. The good news: interviewers keep coming back to the same core ideas. If you truly understand the event loop, async code, streams and how Node.js scales, you can answer most questions with confidence \u2014 even the tricky &#8220;what is the output?&#8221; puzzles.<\/p>\n<p>In this guide we go through the questions one by one. Each answer has a simple explanation first, then a small code example you can run on your own laptop. No memorising \u2014 the goal is to understand.<\/p>\n<\/div>\n\n\n\n<div class=\"dd-post\">\n<h2 id=\"how-to-use\">How to Use This Guide<\/h2>\n<p>Questions are tagged by level so you can focus on what matters for your role:<\/p>\n<ul>\n<li><span class=\"tag t-b\" style=\"display:inline-block;font-size:12px;font-weight:700;padding:3px 9px;border-radius:20px;background:#e5f6ec;color:#16784a\">Beginner<\/span> \u2014 expected for freshers and interns.<\/li>\n<li><span class=\"tag t-i\" style=\"display:inline-block;font-size:12px;font-weight:700;padding:3px 9px;border-radius:20px;background:#e8efff;color:#2459a8\">Intermediate<\/span> \u2014 expected with 1\u20133 years of experience.<\/li>\n<li><span class=\"tag t-a\" style=\"display:inline-block;font-size:12px;font-weight:700;padding:3px 9px;border-radius:20px;background:#efe9ff;color:#5a3cc7\">Advanced<\/span> \u2014 senior-leaning questions that show deeper understanding.<\/li>\n<\/ul>\n<div class=\"dd-note\"><strong>Which Node.js version?<\/strong> Use an LTS (Long-Term Support) version. Node.js 24 is the current Active LTS, and Node.js 26 is scheduled to become LTS on 28 October. All examples here work on both. You can check the official dates on the <a href=\"https:\/\/github.com\/nodejs\/Release\" target=\"_blank\" rel=\"noopener\">Node.js release schedule<\/a>.<\/div>\n\n<h2 id=\"basics\">Node.js Basics Questions<\/h2>\n\n<div class=\"dd-q\">\n<h3>1. What is Node.js? <span class=\"tag t-b\">Beginner<\/span><\/h3>\n<p>Node.js is a <strong>runtime<\/strong> that lets you run JavaScript outside the browser \u2014 on servers, laptops and build tools. It uses Google&#8217;s <strong>V8 engine<\/strong> to run your code and a C library called <strong>libuv<\/strong> to handle files, network and timers without blocking.<\/p>\n<p><strong>Say this in the interview:<\/strong> &#8220;Node.js is a JavaScript runtime built on V8. It uses an event-driven, non-blocking I\/O model, which makes it great for APIs, real-time apps and tools that handle many connections at once.&#8221;<\/p>\n<\/div>\n\n<div class=\"dd-q\">\n<h3>2. Is Node.js single-threaded? <span class=\"tag t-i\">Intermediate<\/span><\/h3>\n<p>Your JavaScript runs on <strong>one main thread<\/strong>. But Node.js itself is not fully single-threaded. libuv keeps a small <strong>thread pool<\/strong> (4 threads by default) for slow work like file system calls, DNS lookups, compression and some crypto. Network sockets use the operating system&#8217;s own async features.<\/p>\n<p>So the correct answer is: &#8220;JavaScript execution is single-threaded, but Node.js uses extra threads in the background for I\/O. And we can create more threads ourselves with <code>worker_threads<\/code>.&#8221;<\/p>\n<\/div>\n\n<div class=\"dd-q\">\n<h3>3. What is the difference between blocking and non-blocking code? <span class=\"tag t-b\">Beginner<\/span><\/h3>\n<p><strong>Blocking<\/strong> code makes the main thread wait until the task finishes. While it waits, Node.js cannot serve any other request. <strong>Non-blocking<\/strong> code starts the task, moves on, and runs a callback (or resolves a promise) when the result is ready.<\/p>\n<p class=\"dd-file\">blocking.mjs<\/p>\n<pre><code>import { readFileSync } from 'node:fs';\nimport { readFile } from 'node:fs\/promises';\n\n\/\/ Blocking: nothing else can run until the file is fully read\nconst a = readFileSync('.\/package.json', 'utf8');\nconsole.log('sync read done:', a.length, 'chars');\n\n\/\/ Non-blocking: the main thread is free while the OS reads the file\nconst pending = readFile('.\/package.json', 'utf8');\nconsole.log('this line runs before the async read finishes');\nconst b = await pending;\nconsole.log('async read done:', b.length, 'chars');<\/code><\/pre>\n<div class=\"dd-tip\"><strong>Rule of thumb:<\/strong> <code>*Sync<\/code> functions are fine in startup scripts and CLI tools. Avoid them inside request handlers of a web server.<\/div>\n<\/div>\n\n<div class=\"dd-q\">\n<h3>4. What is the difference between CommonJS and ES Modules? <span class=\"tag t-b\">Beginner<\/span><\/h3>\n<p><strong>CommonJS<\/strong> (CJS) is Node&#8217;s original module system: <code>require()<\/code> and <code>module.exports<\/code>. <strong>ES Modules<\/strong> (ESM) is the JavaScript standard: <code>import<\/code> and <code>export<\/code>. ESM supports top-level <code>await<\/code> and is what new projects should use.<\/p>\n<p>Node.js treats a file as ESM if it ends in <code>.mjs<\/code>, or ends in <code>.js<\/code> and the nearest <code>package.json<\/code> has <code>\"type\": \"module\"<\/code>. A bonus point for interviews: modern Node versions (22.12+ and later) can <code>require()<\/code> an ES module directly, as long as that module does not use top-level <code>await<\/code>. This removed a big pain point when mixing old and new packages.<\/p>\n<\/div>\n\n<div class=\"dd-q\">\n<h3>5. What is npm, and what is package-lock.json for? <span class=\"tag t-b\">Beginner<\/span><\/h3>\n<p>npm is the package manager that ships with Node.js. <code>package.json<\/code> lists the version <em>ranges<\/em> you accept (like <code>^5.1.0<\/code>). <code>package-lock.json<\/code> records the <em>exact<\/em> versions that were installed, so every developer and every server gets the same dependency tree. In CI, use <code>npm ci<\/code>, which installs strictly from the lock file. (We used exactly this in our <a href=\"\/github-actions-ci-cd-nodejs\/\">GitHub Actions CI\/CD for Node.js guide<\/a>.)<\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"dd-post\">\n<h2 id=\"event-loop\">Event Loop Questions<\/h2>\n<p>The event loop is the number one topic in Node.js interviews. If you can draw it on a whiteboard, you are already ahead of most candidates.<\/p>\n\n<div class=\"dd-q\">\n<h3>6. What is the event loop? <span class=\"tag t-i\">Intermediate<\/span><\/h3>\n<p>The event loop is the mechanism that lets one JavaScript thread handle thousands of operations. Node.js hands slow work (files, network, timers) to the system, and when that work finishes, a callback is placed in a queue. The event loop keeps checking these queues and runs the callbacks one by one, in a fixed order of <strong>phases<\/strong>.<\/p>\n<\/div>\n\n<figure>\n<svg viewBox=\"0 0 900 470\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" role=\"img\" aria-labelledby=\"ddEl1 ddEl1d\">\n<title id=\"ddEl1\">Diagram of the Node.js event loop phases<\/title>\n<desc id=\"ddEl1d\">Five phases in a loop: timers, pending callbacks, poll, check and close callbacks, with the microtask queue for nextTick and promises running between each step.<\/desc>\n<rect width=\"900\" height=\"470\" rx=\"18\" fill=\"#0f1430\"\/>\n<defs><marker id=\"ddArr\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto\"><path d=\"M0 0L10 5L0 10z\" fill=\"#7c5cff\"\/><\/marker><\/defs>\n<ellipse cx=\"450\" cy=\"240\" rx=\"300\" ry=\"160\" fill=\"none\" stroke=\"#2e3770\" stroke-width=\"3\" stroke-dasharray=\"8 8\"\/>\n<g font-family=\"Segoe UI,Arial,sans-serif\" text-anchor=\"middle\">\n<g><rect x=\"370\" y=\"52\" width=\"160\" height=\"56\" rx=\"12\" fill=\"#1b2250\" stroke=\"#3178c6\" stroke-width=\"2\"\/><text x=\"450\" y=\"78\" fill=\"#fff\" font-size=\"17\" font-weight=\"700\">1. Timers<\/text><text x=\"450\" y=\"98\" fill=\"#9aa5d6\" font-size=\"13\">setTimeout, setInterval<\/text><\/g>\n<g><rect x=\"650\" y=\"132\" width=\"180\" height=\"56\" rx=\"12\" fill=\"#1b2250\" stroke=\"#3178c6\" stroke-width=\"2\"\/><text x=\"740\" y=\"158\" fill=\"#fff\" font-size=\"17\" font-weight=\"700\">2. Pending<\/text><text x=\"740\" y=\"178\" fill=\"#9aa5d6\" font-size=\"13\">some system errors<\/text><\/g>\n<g><rect x=\"650\" y=\"292\" width=\"180\" height=\"56\" rx=\"12\" fill=\"#1b2250\" stroke=\"#7c5cff\" stroke-width=\"2\"\/><text x=\"740\" y=\"318\" fill=\"#fff\" font-size=\"17\" font-weight=\"700\">3. Poll<\/text><text x=\"740\" y=\"338\" fill=\"#9aa5d6\" font-size=\"13\">I\/O callbacks (files, net)<\/text><\/g>\n<g><rect x=\"370\" y=\"372\" width=\"160\" height=\"56\" rx=\"12\" fill=\"#1b2250\" stroke=\"#3178c6\" stroke-width=\"2\"\/><text x=\"450\" y=\"398\" fill=\"#fff\" font-size=\"17\" font-weight=\"700\">4. Check<\/text><text x=\"450\" y=\"418\" fill=\"#9aa5d6\" font-size=\"13\">setImmediate<\/text><\/g>\n<g><rect x=\"70\" y=\"292\" width=\"180\" height=\"56\" rx=\"12\" fill=\"#1b2250\" stroke=\"#3178c6\" stroke-width=\"2\"\/><text x=\"160\" y=\"318\" fill=\"#fff\" font-size=\"17\" font-weight=\"700\">5. Close<\/text><text x=\"160\" y=\"338\" fill=\"#9aa5d6\" font-size=\"13\">socket.on(&#8216;close&#8217;)<\/text><\/g>\n<g><rect x=\"70\" y=\"132\" width=\"180\" height=\"56\" rx=\"12\" fill=\"#151b3b\" stroke=\"#2e3770\" stroke-width=\"2\"\/><text x=\"160\" y=\"158\" fill=\"#c9d1ff\" font-size=\"16\" font-weight=\"700\">Loop again?<\/text><text x=\"160\" y=\"178\" fill=\"#9aa5d6\" font-size=\"13\">if work is pending<\/text><\/g>\n<rect x=\"320\" y=\"190\" width=\"260\" height=\"100\" rx=\"14\" fill=\"#231a55\" stroke=\"#a99bff\" stroke-width=\"2\"\/>\n<text x=\"450\" y=\"222\" fill=\"#ffd479\" font-size=\"17\" font-weight=\"700\">Microtask queue<\/text>\n<text x=\"450\" y=\"248\" fill=\"#e6e9f5\" font-size=\"14\">1st: process.nextTick()<\/text>\n<text x=\"450\" y=\"270\" fill=\"#e6e9f5\" font-size=\"14\">2nd: Promise callbacks<\/text>\n<\/g>\n<g stroke=\"#7c5cff\" stroke-width=\"2.5\" fill=\"none\" marker-end=\"url(#ddArr)\">\n<path d=\"M532 84 Q620 95 660 128\"\/><path d=\"M745 192 L745 286\"\/><path d=\"M660 344 Q600 392 536 400\"\/><path d=\"M366 400 Q290 392 248 348\"\/><path d=\"M160 290 L160 194\"\/><path d=\"M250 150 Q300 100 364 84\"\/>\n<\/g>\n<\/svg>\n<figcaption>The event loop runs phases in order. After each callback, Node.js empties the microtask queue (nextTick first, then promises).<\/figcaption>\n<\/figure>\n\n<h3>Explore the phases (click a tab)<\/h3>\n<div class=\"dd-explorer\">\n<input type=\"radio\" name=\"ddphase\" id=\"ddp1\" checked><input type=\"radio\" name=\"ddphase\" id=\"ddp2\"><input type=\"radio\" name=\"ddphase\" id=\"ddp3\"><input type=\"radio\" name=\"ddphase\" id=\"ddp4\"><input type=\"radio\" name=\"ddphase\" id=\"ddp5\"><input type=\"radio\" name=\"ddphase\" id=\"ddp6\">\n<div class=\"tabs\"><label for=\"ddp1\">Timers<\/label><label for=\"ddp2\">Pending<\/label><label for=\"ddp3\">Poll<\/label><label for=\"ddp4\">Check<\/label><label for=\"ddp5\">Close<\/label><label for=\"ddp6\">Microtasks<\/label><\/div>\n<div class=\"panels\">\n<div class=\"panel p1\"><b>Timers phase.<\/b> Runs callbacks from <code>setTimeout<\/code> and <code>setInterval<\/code> whose time has passed. Note: <code>setTimeout(fn, 0)<\/code> means &#8220;at least 0 ms later&#8221;, not &#8220;right now&#8221;. Delays are a minimum, never a guarantee.<\/div>\n<div class=\"panel p2\"><b>Pending callbacks phase.<\/b> Runs a few system-level callbacks that were deferred from the previous loop, such as certain TCP errors. You rarely touch this directly, but naming it shows you know the full picture.<\/div>\n<div class=\"panel p3\"><b>Poll phase.<\/b> The busiest phase. Node.js collects finished I\/O events (file reads, incoming HTTP data) and runs their callbacks. If there is nothing to do, the loop can wait here for new events.<\/div>\n<div class=\"panel p4\"><b>Check phase.<\/b> Runs <code>setImmediate<\/code> callbacks right after the poll phase. That is why, inside an I\/O callback, <code>setImmediate<\/code> always runs before <code>setTimeout(fn, 0)<\/code>.<\/div>\n<div class=\"panel p5\"><b>Close callbacks phase.<\/b> Runs cleanup callbacks such as <code>socket.on('close', ...)<\/code> when a handle is closed abruptly.<\/div>\n<div class=\"panel p6\"><b>Microtasks (between everything).<\/b> Not a phase, but very important. After every single callback, Node.js runs all <code>process.nextTick<\/code> callbacks, then all promise callbacks (<code>.then<\/code>, code after <code>await<\/code>). Too many microtasks can starve the event loop.<\/div>\n<\/div>\n<\/div>\n\n<div class=\"dd-q\">\n<h3>7. What is the output of this code? <span class=\"tag t-a\">Advanced<\/span><\/h3>\n<p>This &#8220;guess the order&#8221; puzzle is very common. Try to answer before opening the solution.<\/p>\n<p class=\"dd-file\">order.cjs<\/p>\n<pre><code>const fs = require('node:fs');\n\nfs.readFile(__filename, () =&gt; {\n  setTimeout(() =&gt; console.log('setTimeout'), 0);\n  setImmediate(() =&gt; console.log('setImmediate'));\n  Promise.resolve().then(() =&gt; console.log('promise'));\n  process.nextTick(() =&gt; console.log('nextTick'));\n  console.log('inside I\/O callback');\n});\n\nconsole.log('main script');<\/code><\/pre>\n<details>\n<summary>Show the answer and explanation<\/summary>\n<pre><code>main script\ninside I\/O callback\nnextTick\npromise\nsetImmediate\nsetTimeout<\/code><\/pre>\n<p><strong>Why:<\/strong> synchronous code runs first. The file read finishes later in the <em>poll<\/em> phase. Inside that callback, the sync <code>console.log<\/code> runs, then the microtask queue empties (<code>nextTick<\/code> before <code>promise<\/code>). Next comes the <em>check<\/em> phase (<code>setImmediate<\/code>), and only on the next loop the <em>timers<\/em> phase (<code>setTimeout<\/code>).<\/p>\n<p><strong>Trap:<\/strong> if you put <code>setTimeout<\/code> and <code>setImmediate<\/code> in the main script (not inside an I\/O callback), their order is <em>not guaranteed<\/em>. Saying this out loud impresses interviewers. Also note we used a <code>.cjs<\/code> file on purpose: in ES modules, the promise can run before <code>nextTick<\/code>, because the module itself is already running inside a microtask.<\/p>\n<\/details>\n<\/div>\n\n<div class=\"dd-q\">\n<h3>8. What is the difference between process.nextTick() and setImmediate()? <span class=\"tag t-i\">Intermediate<\/span><\/h3>\n<p>The names are confusing \u2014 they are almost swapped! <code>process.nextTick()<\/code> runs <strong>immediately after the current operation<\/strong>, before the event loop continues. <code>setImmediate()<\/code> runs in the <strong>check phase<\/strong> of the next loop iteration. Prefer <code>setImmediate()<\/code> or <code>queueMicrotask()<\/code> in normal code; a recursive <code>nextTick<\/code> can block I\/O forever.<\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"dd-post\">\n<h2 id=\"async\">Async Code Questions<\/h2>\n\n<div class=\"dd-q\">\n<h3>9. Callbacks vs Promises vs async\/await \u2014 what is the difference? <span class=\"tag t-b\">Beginner<\/span><\/h3>\n<p>They are three styles of handling a result that arrives later. <strong>Callbacks<\/strong> pass a function to be called later (error first: <code>(err, data)<\/code>). Nesting many callbacks leads to &#8220;callback hell&#8221;. <strong>Promises<\/strong> represent a future value and can be chained with <code>.then()<\/code>. <strong>async\/await<\/strong> is cleaner syntax on top of promises that reads like normal top-to-bottom code. For a deeper refresher, read our <a href=\"\/mastering-javascript-promises-a-guide-to-asynchronous-programming\/\">guide to JavaScript Promises<\/a>.<\/p>\n<p class=\"dd-file\">styles.mjs<\/p>\n<pre><code>import fs from 'node:fs';\nimport { promisify } from 'node:util';\n\n\/\/ 1) Callback style (error-first)\nfs.readFile('.\/package.json', 'utf8', (err, data) =&gt; {\n  if (err) return console.error('callback error:', err.message);\n  console.log('callback:', JSON.parse(data).name);\n});\n\n\/\/ 2) Promise style\nconst readFileP = promisify(fs.readFile);\nreadFileP('.\/package.json', 'utf8')\n  .then((data) =&gt; console.log('promise:', JSON.parse(data).name))\n  .catch((err) =&gt; console.error('promise error:', err.message));\n\n\/\/ 3) async\/await style (most readable)\ntry {\n  const data = await fs.promises.readFile('.\/package.json', 'utf8');\n  console.log('await:', JSON.parse(data).name);\n} catch (err) {\n  console.error('await error:', err.message);\n}<\/code><\/pre>\n<\/div>\n\n<div class=\"dd-q\">\n<h3>10. Promise.all vs Promise.allSettled vs Promise.race vs Promise.any? <span class=\"tag t-i\">Intermediate<\/span><\/h3>\n<ul>\n<li><code>Promise.all<\/code> \u2014 waits for all; <strong>fails fast<\/strong> if any one rejects.<\/li>\n<li><code>Promise.allSettled<\/code> \u2014 waits for all and gives you every result, success or failure.<\/li>\n<li><code>Promise.race<\/code> \u2014 settles with the <strong>first<\/strong> promise to finish (success or failure).<\/li>\n<li><code>Promise.any<\/code> \u2014 resolves with the first <strong>success<\/strong>; rejects only if all fail.<\/li>\n<\/ul>\n<p>Here is a real-world example: call several APIs in parallel, with a timeout, and report every result. Node.js has a built-in <code>fetch<\/code>, so no extra package is needed.<\/p>\n<p class=\"dd-file\">parallel.mjs<\/p>\n<pre><code>const urls = [\n  'https:\/\/api.github.com\/users\/nodejs',\n  'https:\/\/api.github.com\/users\/this-user-should-not-exist-404',\n  'https:\/\/example.invalid\/',\n];\n\nconst results = await Promise.allSettled(\n  urls.map(async (url) =&gt; {\n    \/\/ Cancel the request if it takes longer than 3 seconds\n    const res = await fetch(url, { signal: AbortSignal.timeout(3000) });\n    if (!res.ok) throw new Error(`HTTP ${res.status} for ${url}`);\n    return res.json();\n  })\n);\n\nfor (const r of results) {\n  console.log(r.status === 'fulfilled' ? `OK: ${r.value.login}` : `FAILED: ${r.reason.message}`);\n}<\/code><\/pre>\n<div class=\"dd-tip\"><strong>Interview tip:<\/strong> mention that a common bug is using <code>await<\/code> inside a <code>for<\/code> loop for independent calls. That runs them one after another. Use <code>Promise.all<\/code> to run them in parallel.<\/div>\n<\/div>\n\n<div class=\"dd-q\">\n<h3>11. How do you handle errors in async code? <span class=\"tag t-i\">Intermediate<\/span><\/h3>\n<p>Use <code>try\/catch<\/code> around <code>await<\/code>, or <code>.catch()<\/code> on promise chains. Never leave a promise without error handling: since Node.js 15, an <strong>unhandled promise rejection crashes the process<\/strong> by default. As a last line of defence, log and exit cleanly:<\/p>\n<pre><code>process.on('unhandledRejection', (reason) =&gt; {\n  console.error('Unhandled rejection:', reason);\n  process.exit(1); \/\/ let your process manager (Docker, PM2, systemd) restart the app\n});<\/code><\/pre>\n<\/div>\n\n<div class=\"dd-q\">\n<h3>12. What is an EventEmitter? <span class=\"tag t-b\">Beginner<\/span><\/h3>\n<p><code>EventEmitter<\/code> is the class behind most Node.js APIs (HTTP servers, streams, sockets). You <code>emit<\/code> named events and other code listens with <code>on<\/code>. It is the &#8220;publish \/ subscribe&#8221; pattern.<\/p>\n<p class=\"dd-file\">orders.mjs<\/p>\n<pre><code>import { EventEmitter } from 'node:events';\n\nclass OrderService extends EventEmitter {\n  place(order) {\n    \/\/ ...save the order to the database...\n    this.emit('order:placed', order);\n  }\n}\n\nconst orders = new OrderService();\norders.on('order:placed', (o) =&gt; console.log(`Send email for order #${o.id}`));\norders.on('order:placed', (o) =&gt; console.log(`Update stock for ${o.item}`));\n\norders.place({ id: 101, item: 'Mechanical keyboard' });<\/code><\/pre>\n<div class=\"dd-warn\"><strong>Watch out:<\/strong> if you emit an <code>'error'<\/code> event and nobody listens for it, Node.js throws and can crash the process. Always add an <code>error<\/code> listener.<\/div>\n<\/div>\n<\/div>\n\n\n\n<div class=\"dd-post\">\n<h2 id=\"streams\">Streams and Buffers Questions<\/h2>\n\n<div class=\"dd-q\">\n<h3>13. What are streams, and why use them? <span class=\"tag t-i\">Intermediate<\/span><\/h3>\n<p>A stream processes data <strong>piece by piece<\/strong> (in chunks) instead of loading everything into memory. Reading a 5 GB log file with <code>readFile<\/code> can crash your server; with a stream, memory stays small and steady. There are four types: <strong>Readable<\/strong>, <strong>Writable<\/strong>, <strong>Duplex<\/strong> (both, like a TCP socket) and <strong>Transform<\/strong> (changes data as it passes, like gzip).<\/p>\n<p>The modern way to connect streams is <code>pipeline<\/code> from <code>node:stream\/promises<\/code>. It handles errors and cleanup for you \u2014 something plain <code>.pipe()<\/code> does not do.<\/p>\n<p class=\"dd-file\">compress.mjs<\/p>\n<pre><code>import { createReadStream, createWriteStream } from 'node:fs';\nimport { createGzip } from 'node:zlib';\nimport { pipeline } from 'node:stream\/promises';\n\n\/\/ Usage: node compress.mjs big-file.log\nconst input = process.argv[2] ?? 'big-file.log';\n\ntry {\n  await pipeline(\n    createReadStream(input),          \/\/ Readable\n    createGzip(),                     \/\/ Transform\n    createWriteStream(`${input}.gz`)  \/\/ Writable\n  );\n  console.log(`Compressed ${input} -&gt; ${input}.gz`);\n} catch (err) {\n  console.error('Pipeline failed:', err.message);\n}<\/code><\/pre>\n<\/div>\n\n<div class=\"dd-q\">\n<h3>14. What is backpressure? <span class=\"tag t-a\">Advanced<\/span><\/h3>\n<p>Backpressure happens when data arrives faster than the destination can handle it \u2014 for example, reading a fast disk and writing to a slow network. If you ignore it, data piles up in memory. Streams solve this automatically: when the writable&#8217;s buffer is full, <code>write()<\/code> returns <code>false<\/code> and the readable pauses until a <code>'drain'<\/code> event. Using <code>pipeline()<\/code> gives you this behaviour for free.<\/p>\n<\/div>\n\n<div class=\"dd-q\">\n<h3>15. What is a Buffer? <span class=\"tag t-b\">Beginner<\/span><\/h3>\n<p>A <code>Buffer<\/code> is a fixed-size chunk of raw binary data (bytes). Node.js uses Buffers for files, network packets and images. <code>Buffer.from('hello')<\/code> creates one from a string, and <code>buf.toString('base64')<\/code> converts it. Buffers are a subclass of <code>Uint8Array<\/code>, so they work with standard web APIs too.<\/p>\n<\/div>\n\n<h2 id=\"scaling\">Scaling and Performance Questions<\/h2>\n\n<div class=\"dd-q\">\n<h3>16. Worker threads vs cluster vs child process \u2014 when to use which? <span class=\"tag t-a\">Advanced<\/span><\/h3>\n<p>All three let you use more than one CPU core, but for different jobs:<\/p>\n<\/div>\n\n<figure>\n<svg viewBox=\"0 0 900 380\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" role=\"img\" aria-labelledby=\"ddSc1 ddSc1d\">\n<title id=\"ddSc1\">Comparison of cluster, worker threads and child process in Node.js<\/title>\n<desc id=\"ddSc1d\">Three columns. Cluster: many Node processes sharing one port, best for scaling web servers. Worker threads: threads inside one process with shared memory, best for CPU-heavy tasks. Child process: runs a separate program like ffmpeg or a Python script.<\/desc>\n<rect width=\"900\" height=\"380\" rx=\"18\" fill=\"#0f1430\"\/>\n<g font-family=\"Segoe UI,Arial,sans-serif\" text-anchor=\"middle\">\n<g><rect x=\"30\" y=\"30\" width=\"260\" height=\"320\" rx=\"14\" fill=\"#151b3b\" stroke=\"#3178c6\" stroke-width=\"2\"\/>\n<text x=\"160\" y=\"66\" fill=\"#fff\" font-size=\"21\" font-weight=\"700\">cluster<\/text>\n<text x=\"160\" y=\"90\" fill=\"#9aa5d6\" font-size=\"13\">many processes, one port<\/text>\n<rect x=\"95\" y=\"110\" width=\"130\" height=\"38\" rx=\"8\" fill=\"#3178c6\"\/><text x=\"160\" y=\"135\" fill=\"#fff\" font-size=\"14\" font-weight=\"600\">Primary :3000<\/text>\n<rect x=\"45\" y=\"180\" width=\"70\" height=\"38\" rx=\"8\" fill=\"#1b2250\" stroke=\"#5aa2f0\"\/><text x=\"80\" y=\"204\" fill=\"#e6e9f5\" font-size=\"13\">Node<\/text>\n<rect x=\"125\" y=\"180\" width=\"70\" height=\"38\" rx=\"8\" fill=\"#1b2250\" stroke=\"#5aa2f0\"\/><text x=\"160\" y=\"204\" fill=\"#e6e9f5\" font-size=\"13\">Node<\/text>\n<rect x=\"205\" y=\"180\" width=\"70\" height=\"38\" rx=\"8\" fill=\"#1b2250\" stroke=\"#5aa2f0\"\/><text x=\"240\" y=\"204\" fill=\"#e6e9f5\" font-size=\"13\">Node<\/text>\n<path d=\"M140 148L80 180M160 148L160 180M180 148L240 180\" stroke=\"#5aa2f0\" stroke-width=\"2\"\/>\n<text x=\"160\" y=\"262\" fill=\"#ffd479\" font-size=\"15\" font-weight=\"700\">Best for:<\/text>\n<text x=\"160\" y=\"286\" fill=\"#e6e9f5\" font-size=\"14\">scaling an HTTP server<\/text>\n<text x=\"160\" y=\"308\" fill=\"#e6e9f5\" font-size=\"14\">across all CPU cores<\/text><\/g>\n<g><rect x=\"320\" y=\"30\" width=\"260\" height=\"320\" rx=\"14\" fill=\"#151b3b\" stroke=\"#7c5cff\" stroke-width=\"2\"\/>\n<text x=\"450\" y=\"66\" fill=\"#fff\" font-size=\"21\" font-weight=\"700\">worker_threads<\/text>\n<text x=\"450\" y=\"90\" fill=\"#9aa5d6\" font-size=\"13\">threads in one process<\/text>\n<rect x=\"345\" y=\"110\" width=\"210\" height=\"110\" rx=\"10\" fill=\"none\" stroke=\"#a99bff\" stroke-dasharray=\"6 6\"\/>\n<rect x=\"360\" y=\"124\" width=\"80\" height=\"34\" rx=\"8\" fill=\"#7c5cff\"\/><text x=\"400\" y=\"146\" fill=\"#fff\" font-size=\"13\" font-weight=\"600\">main<\/text>\n<rect x=\"460\" y=\"124\" width=\"80\" height=\"34\" rx=\"8\" fill=\"#1b2250\" stroke=\"#a99bff\"\/><text x=\"500\" y=\"146\" fill=\"#e6e9f5\" font-size=\"13\">worker<\/text>\n<rect x=\"410\" y=\"172\" width=\"80\" height=\"34\" rx=\"8\" fill=\"#1b2250\" stroke=\"#a99bff\"\/><text x=\"450\" y=\"194\" fill=\"#e6e9f5\" font-size=\"13\">worker<\/text>\n<text x=\"450\" y=\"262\" fill=\"#ffd479\" font-size=\"15\" font-weight=\"700\">Best for:<\/text>\n<text x=\"450\" y=\"286\" fill=\"#e6e9f5\" font-size=\"14\">CPU-heavy work: hashing,<\/text>\n<text x=\"450\" y=\"308\" fill=\"#e6e9f5\" font-size=\"14\">image resizing, big JSON<\/text><\/g>\n<g><rect x=\"610\" y=\"30\" width=\"260\" height=\"320\" rx=\"14\" fill=\"#151b3b\" stroke=\"#3178c6\" stroke-width=\"2\"\/>\n<text x=\"740\" y=\"66\" fill=\"#fff\" font-size=\"21\" font-weight=\"700\">child_process<\/text>\n<text x=\"740\" y=\"90\" fill=\"#9aa5d6\" font-size=\"13\">run another program<\/text>\n<rect x=\"675\" y=\"110\" width=\"130\" height=\"38\" rx=\"8\" fill=\"#3178c6\"\/><text x=\"740\" y=\"135\" fill=\"#fff\" font-size=\"14\" font-weight=\"600\">Node app<\/text>\n<path d=\"M740 148V180\" stroke=\"#5aa2f0\" stroke-width=\"2\"\/>\n<rect x=\"650\" y=\"180\" width=\"180\" height=\"38\" rx=\"8\" fill=\"#1b2250\" stroke=\"#5aa2f0\"\/><text x=\"740\" y=\"204\" fill=\"#e6e9f5\" font-size=\"13\">ffmpeg \/ python \/ git<\/text>\n<text x=\"740\" y=\"262\" fill=\"#ffd479\" font-size=\"15\" font-weight=\"700\">Best for:<\/text>\n<text x=\"740\" y=\"286\" fill=\"#e6e9f5\" font-size=\"14\">calling shell commands<\/text>\n<text x=\"740\" y=\"308\" fill=\"#e6e9f5\" font-size=\"14\">or non-JS tools<\/text><\/g>\n<\/g>\n<\/svg>\n<figcaption>Pick the tool by the job: cluster for more web traffic, worker threads for heavy calculations, child process for other programs.<\/figcaption>\n<\/figure>\n\n<p>Here is a worker thread doing a slow calculation, so the main thread stays free to answer HTTP requests:<\/p>\n<p class=\"dd-file\">fib-worker.mjs<\/p>\n<pre><code>import { Worker, isMainThread, parentPort, workerData } from 'node:worker_threads';\n\nfunction fib(n) {\n  return n &lt; 2 ? n : fib(n - 1) + fib(n - 2); \/\/ deliberately slow (CPU-heavy)\n}\n\nif (isMainThread) {\n  \/\/ Main thread: start a worker running this same file\n  const worker = new Worker(new URL(import.meta.url), { workerData: 40 });\n  worker.on('message', (result) =&gt; console.log('fib(40) =', result));\n  worker.on('error', (err) =&gt; console.error('Worker failed:', err));\n  console.log('Main thread is still free while the worker calculates...');\n} else {\n  \/\/ Worker thread: do the heavy work and send the result back\n  parentPort.postMessage(fib(workerData));\n}<\/code><\/pre>\n<p>In production, most teams don&#8217;t use <code>cluster<\/code> by hand. They run several containers behind a load balancer (see our <a href=\"\/docker-compose-tutorial\/\">Docker Compose tutorial<\/a>) or use a process manager like PM2.<\/p>\n\n<div class=\"dd-q\">\n<h3>17. How do you find a memory leak or slow code? <span class=\"tag t-a\">Advanced<\/span><\/h3>\n<p>Start with <code>process.memoryUsage()<\/code> to watch heap growth over time. Then run <code>node --inspect app.js<\/code> and open <code>chrome:\/\/inspect<\/code> to take <strong>heap snapshots<\/strong> and <strong>CPU profiles<\/strong>. Common leak causes: global arrays or caches that never shrink, event listeners added on every request and never removed, and timers that are never cleared.<\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"dd-post\">\n<h2 id=\"modern-node\">Modern Node.js Features Questions<\/h2>\n<p>Interviewers increasingly ask, &#8220;Which new Node.js features do you use?&#8221; It checks whether you keep up. These are all built in \u2014 no extra packages:<\/p>\n\n<div class=\"dd-q\">\n<h3>18. What tools are now built into Node.js? <span class=\"tag t-i\">Intermediate<\/span><\/h3>\n<ul>\n<li><strong><code>fetch<\/code><\/strong> \u2014 the same API as the browser, for HTTP requests.<\/li>\n<li><strong><code>node --watch app.js<\/code><\/strong> \u2014 restarts on file changes (replaces nodemon for many projects).<\/li>\n<li><strong><code>node --env-file=.env app.js<\/code><\/strong> \u2014 loads environment variables without the <code>dotenv<\/code> package.<\/li>\n<li><strong><code>node:test<\/code><\/strong> \u2014 a built-in test runner with <code>describe<\/code>, <code>it<\/code> and mocking.<\/li>\n<li><strong>Running TypeScript directly<\/strong> \u2014 recent versions strip type annotations, so <code>node app.ts<\/code> works for code that only uses &#8220;erasable&#8221; TypeScript syntax (no <code>enum<\/code> or <code>namespace<\/code>). Read the <a href=\"https:\/\/nodejs.org\/api\/typescript.html\" target=\"_blank\" rel=\"noopener\">official Node.js TypeScript docs<\/a> for the details, and see our <a href=\"\/typescript-7-migration-guide\/\">TypeScript 7 migration guide<\/a> for type checking.<\/li>\n<\/ul>\n<p>Here is a complete test using only the built-in runner. Run it with <code>node --test<\/code>:<\/p>\n<p class=\"dd-file\">math.test.mjs<\/p>\n<pre><code>import { describe, it } from 'node:test';\nimport assert from 'node:assert\/strict';\n\nfunction applyDiscount(price, percent) {\n  if (percent &lt; 0 || percent &gt; 100) throw new RangeError('percent must be 0-100');\n  return Math.round(price * (100 - percent)) \/ 100;\n}\n\ndescribe('applyDiscount', () =&gt; {\n  it('applies a 10% discount', () =&gt; {\n    assert.equal(applyDiscount(500, 10), 450);\n  });\n\n  it('throws for an invalid percent', () =&gt; {\n    assert.throws(() =&gt; applyDiscount(500, 120), RangeError);\n  });\n});<\/code><\/pre>\n<\/div>\n\n<h2 id=\"express-api\">API and Express Questions<\/h2>\n\n<div class=\"dd-q\">\n<h3>19. What is middleware in Express? <span class=\"tag t-b\">Beginner<\/span><\/h3>\n<p>Middleware is a function that runs <strong>between<\/strong> the incoming request and your final route handler. It receives <code>(req, res, next)<\/code> and can read or change the request, end the response, or call <code>next()<\/code> to pass control on. Logging, authentication, body parsing and rate limiting are all middleware. An <strong>error-handling middleware<\/strong> has four arguments: <code>(err, req, res, next)<\/code>.<\/p>\n<p>In Express 5, if an <code>async<\/code> route throws or rejects, the error goes to your error handler automatically \u2014 no more wrapping every route in <code>try\/catch<\/code>.<\/p>\n<p class=\"dd-file\">server.mjs<\/p>\n<pre><code>\/\/ npm install express\nimport express from 'express';\n\nconst app = express();\napp.use(express.json());\n\n\/\/ Simple logging middleware\napp.use((req, res, next) =&gt; {\n  const start = Date.now();\n  res.on('finish', () =&gt; console.log(`${req.method} ${req.url} ${res.statusCode} ${Date.now() - start}ms`));\n  next();\n});\n\napp.get('\/users\/:id', async (req, res) =&gt; {\n  const id = Number(req.params.id);\n  if (!Number.isInteger(id)) {\n    const err = new Error('User id must be a number');\n    err.status = 400;\n    throw err; \/\/ Express 5 forwards this to the error handler\n  }\n  res.json({ id, name: 'Asha' });\n});\n\n\/\/ Error-handling middleware: 4 arguments, registered last\napp.use((err, req, res, next) =&gt; {\n  res.status(err.status ?? 500).json({ error: err.message });\n});\n\napp.listen(3000, () =&gt; console.log('API running on http:\/\/localhost:3000'));<\/code><\/pre>\n<\/div>\n\n<div class=\"dd-q\">\n<h3>20. How do you keep a Node.js API secure? <span class=\"tag t-i\">Intermediate<\/span><\/h3>\n<p>A good short answer covers: validate all input (for example with Zod), use parameterised queries to stop SQL injection, keep secrets in environment variables (never in Git), add security headers (the <code>helmet<\/code> package), rate-limit login routes, run <code>npm audit<\/code> in CI, and keep Node.js on a supported LTS version so you get security patches.<\/p>\n<\/div>\n<\/div>\n\n\n\n<div class=\"dd-post\">\n<h2 id=\"mistakes\">Common Mistakes and Fixes<\/h2>\n<p>Interviewers love asking &#8220;What went wrong here?&#8221; These are the errors you will see most in real Node.js projects:<\/p>\n<div class=\"dd-tablewrap\">\n<table>\n<thead><tr><th>Error or symptom<\/th><th>Why it happens<\/th><th>Fix<\/th><\/tr><\/thead>\n<tbody>\n<tr><td><code>Cannot use import statement outside a module<\/code><\/td><td>The file is treated as CommonJS.<\/td><td>Add <code>\"type\": \"module\"<\/code> to <code>package.json<\/code> or rename the file to <code>.mjs<\/code>.<\/td><\/tr>\n<tr><td><code>ERR_HTTP_HEADERS_SENT<\/code><\/td><td>The code sends a response twice, often a missing <code>return<\/code>.<\/td><td>Use <code>return res.json(...)<\/code> so the function stops after responding.<\/td><\/tr>\n<tr><td><code>EADDRINUSE: address already in use :::3000<\/code><\/td><td>Another process already uses the port.<\/td><td>Stop the old process or use <code>process.env.PORT<\/code> with a different value.<\/td><\/tr>\n<tr><td>Process crashes with &#8220;unhandled rejection&#8221;<\/td><td>A promise rejected and nothing caught it.<\/td><td>Add <code>try\/catch<\/code> around <code>await<\/code>, or <code>.catch()<\/code> on chains.<\/td><\/tr>\n<tr><td>Server freezes under load<\/td><td>CPU-heavy work or <code>*Sync<\/code> calls block the event loop.<\/td><td>Move heavy work to <code>worker_threads<\/code>; use async APIs.<\/td><\/tr>\n<tr><td><code>MaxListenersExceededWarning<\/code><\/td><td>Listeners are added on every request and never removed.<\/td><td>Add listeners once, or use <code>once()<\/code> \/ <code>off()<\/code>.<\/td><\/tr>\n<tr><td>Slow API with many awaits in a loop<\/td><td>Independent calls run one by one.<\/td><td>Run them together with <code>Promise.all<\/code>.<\/td><\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n\n<h2 id=\"tips\">Interview Tips and Best Practices<\/h2>\n<ul>\n<li><strong>Explain, then show.<\/strong> Give a one-line answer, then a tiny example. Interviewers want to see that you understand <em>why<\/em>.<\/li>\n<li><strong>Draw the event loop.<\/strong> If there is a whiteboard, sketch the phases and the microtask queue. It shows clear thinking.<\/li>\n<li><strong>Talk about trade-offs.<\/strong> &#8220;Node.js is great for I\/O-heavy APIs, but for CPU-heavy work I would use worker threads or a different service.&#8221;<\/li>\n<li><strong>Mention production habits.<\/strong> Logging, graceful shutdown on <code>SIGTERM<\/code>, health-check routes, and CI tests show real-world experience.<\/li>\n<li><strong>Build one small project.<\/strong> A REST API with tests, a database and a Dockerfile gives you stories to tell for almost every question.<\/li>\n<li><strong>Know your version.<\/strong> Say which Node.js LTS you use and one new feature you like. It signals that you keep learning.<\/li>\n<\/ul>\n<div class=\"dd-tip\"><strong>Practice idea:<\/strong> run every code example in this post, then change one line and predict the new output before running it again. This is the fastest way to make the event loop &#8220;click&#8221;.<\/div>\n\n<h2 id=\"faq\">Frequently Asked Questions<\/h2>\n<details>\n<summary>What are the most asked Node.js interview questions for freshers?<\/summary>\n<p>For freshers, expect: What is Node.js? Is it single-threaded? What is the event loop? Blocking vs non-blocking code, callbacks vs promises vs async\/await, CommonJS vs ES Modules, what npm and <code>package.json<\/code> do, and what Express middleware is.<\/p>\n<\/details>\n<details>\n<summary>Is Node.js good for CPU-heavy tasks?<\/summary>\n<p>Not on the main thread. Long calculations block the event loop and every other request waits. Move CPU-heavy work to <code>worker_threads<\/code>, a job queue, or a separate service written in a language better suited to it.<\/p>\n<\/details>\n<details>\n<summary>Which Node.js version should I learn for interviews?<\/summary>\n<p>Learn on the current LTS version. Node.js 24 is in Active LTS, and Node.js 26 becomes LTS at the end of October. The core concepts \u2014 event loop, streams, async code \u2014 are the same in both.<\/p>\n<\/details>\n<details>\n<summary>Do I need to know Express for a Node.js interview?<\/summary>\n<p>Usually yes. Express is still the most common web framework in job descriptions. Knowing routing, middleware and error handling is enough for most roles. Knowing a second framework like Fastify or NestJS is a bonus.<\/p>\n<\/details>\n<details>\n<summary>What is the difference between Node.js and JavaScript?<\/summary>\n<p>JavaScript is the programming language. Node.js is a runtime that runs JavaScript outside the browser and adds server APIs like the file system, HTTP and streams. Browsers add different APIs, like the DOM.<\/p>\n<\/details>\n\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>Most Node.js interview questions come from a few core ideas: one JavaScript thread plus an event loop, non-blocking I\/O, promises and async\/await, streams for big data, and the right tool for scaling. Understand those, run the examples above, and you will be able to answer both the simple questions and the tricky &#8220;what is the output?&#8221; puzzles calmly.<\/p>\n<p>Bookmark this page, practise one section a day, and try explaining each answer to a friend. If you can teach it, you can answer it in an interview.<\/p>\n\n<div class=\"dd-cta\">\n<h3>New posts every day on DevDojo<\/h3>\n<p>We publish practical, beginner-friendly guides on Node.js, React, Python, AI and DevOps every day. Next, set up automatic testing for your project with our <a href=\"\/github-actions-ci-cd-nodejs\/\">GitHub Actions CI\/CD guide for Node.js<\/a> \u2014 and leave your toughest interview question in the comments below.<\/p>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Prepare for your next job with these Node.js interview questions and answers: event loop, async\/await, streams, worker threads and modern Node, with code.<\/p>\n","protected":false},"author":1,"featured_media":194,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,21,8],"tags":[84,85,82,81,83,43],"class_list":["post-195","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-backend","category-interview-questions","category-nodejs","tag-backend","tag-career","tag-event-loop","tag-interview-questions","tag-javascript","tag-node-js"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.2.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"Prepare for your next job with these Node.js interview questions and answers: event loop, async\/await, streams, worker threads and modern Node, with code.\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Lokendra\"\/>\n\t<link rel=\"canonical\" href=\"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.2.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"DevDojo - Empowering Developers\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"Node.js Interview Questions and Answers for Developers\" \/>\n\t\t<meta property=\"og:description\" content=\"Prepare for your next job with these Node.js interview questions and answers: event loop, async\/await, streams, worker threads and modern Node, with code.\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2026-10-12T13:39:03+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2026-10-12T13:39:03+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n\t\t<meta name=\"twitter:title\" content=\"Node.js Interview Questions and Answers for Developers\" \/>\n\t\t<meta name=\"twitter:description\" content=\"Prepare for your next job with these Node.js interview questions and answers: event loop, async\/await, streams, worker threads and modern Node, with code.\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BlogPosting\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/12\\\/nodejs-interview-questions\\\/#blogposting\",\"name\":\"Node.js Interview Questions and Answers for Developers\",\"headline\":\"Node.js Interview Questions and Answers: Event Loop, Async and More\",\"author\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/nodejs-interview-questions.jpg\",\"width\":1200,\"height\":630,\"caption\":\"Node.js interview questions banner showing the event loop connected to async\\\/await, streams, workers and modern Node\"},\"datePublished\":\"2026-10-12T13:39:03+00:00\",\"dateModified\":\"2026-10-12T13:39:03+00:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/12\\\/nodejs-interview-questions\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/12\\\/nodejs-interview-questions\\\/#webpage\"},\"articleSection\":\"Backend, Interview Questions, NodeJS, Backend, Career, Event Loop, Interview Questions, JavaScript, Node.js\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/12\\\/nodejs-interview-questions\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/devdojo.co.in\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/#listItem\",\"name\":\"Backend\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/#listItem\",\"position\":2,\"name\":\"Backend\",\"item\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/nodejs\\\/#listItem\",\"name\":\"NodeJS\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/nodejs\\\/#listItem\",\"position\":3,\"name\":\"NodeJS\",\"item\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/nodejs\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/12\\\/nodejs-interview-questions\\\/#listItem\",\"name\":\"Node.js Interview Questions and Answers: Event Loop, Async and More\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/#listItem\",\"name\":\"Backend\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/12\\\/nodejs-interview-questions\\\/#listItem\",\"position\":4,\"name\":\"Node.js Interview Questions and Answers: Event Loop, Async and More\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/category\\\/backend\\\/nodejs\\\/#listItem\",\"name\":\"NodeJS\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#organization\",\"name\":\"DevDojo\",\"description\":\"Empowering Developers\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/#author\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/\",\"name\":\"Lokendra\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/12\\\/nodejs-interview-questions\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/99f102f0cc9080237ce54b91304fd1b3b6fa29925cbaeba93cd796872e58b45c?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Lokendra\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/12\\\/nodejs-interview-questions\\\/#webpage\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/12\\\/nodejs-interview-questions\\\/\",\"name\":\"Node.js Interview Questions and Answers for Developers\",\"description\":\"Prepare for your next job with these Node.js interview questions and answers: event loop, async\\\/await, streams, worker threads and modern Node, with code.\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/12\\\/nodejs-interview-questions\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/author\\\/lokendra\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/nodejs-interview-questions.jpg\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/12\\\/nodejs-interview-questions\\\/#mainImage\",\"width\":1200,\"height\":630,\"caption\":\"Node.js interview questions banner showing the event loop connected to async\\\/await, streams, workers and modern Node\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/index.php\\\/2026\\\/10\\\/12\\\/nodejs-interview-questions\\\/#mainImage\"},\"datePublished\":\"2026-10-12T13:39:03+00:00\",\"dateModified\":\"2026-10-12T13:39:03+00:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#website\",\"url\":\"https:\\\/\\\/devdojo.co.in\\\/\",\"name\":\"DevDojo\",\"description\":\"Empowering Developers\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/devdojo.co.in\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"Node.js Interview Questions and Answers for Developers","description":"Prepare for your next job with these Node.js interview questions and answers: event loop, async\/await, streams, worker threads and modern Node, with code.","canonical_url":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/","robots":"max-image-preview:large","keywords":"","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BlogPosting","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/#blogposting","name":"Node.js Interview Questions and Answers for Developers","headline":"Node.js Interview Questions and Answers: Event Loop, Async and More","author":{"@id":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/#author"},"publisher":{"@id":"https:\/\/devdojo.co.in\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/devdojo.co.in\/wp-content\/uploads\/2026\/10\/nodejs-interview-questions.jpg","width":1200,"height":630,"caption":"Node.js interview questions banner showing the event loop connected to async\/await, streams, workers and modern Node"},"datePublished":"2026-10-12T13:39:03+00:00","dateModified":"2026-10-12T13:39:03+00:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/#webpage"},"isPartOf":{"@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/#webpage"},"articleSection":"Backend, Interview Questions, NodeJS, Backend, Career, Event Loop, Interview Questions, JavaScript, Node.js"},{"@type":"BreadcrumbList","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/#listItem","position":1,"name":"Home","item":"https:\/\/devdojo.co.in\/","nextItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/#listItem","name":"Backend"}},{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/#listItem","position":2,"name":"Backend","item":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/","nextItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/nodejs\/#listItem","name":"NodeJS"},"previousItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/nodejs\/#listItem","position":3,"name":"NodeJS","item":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/nodejs\/","nextItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/#listItem","name":"Node.js Interview Questions and Answers: Event Loop, Async and More"},"previousItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/#listItem","name":"Backend"}},{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/#listItem","position":4,"name":"Node.js Interview Questions and Answers: Event Loop, Async and More","previousItem":{"@type":"ListItem","@id":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/nodejs\/#listItem","name":"NodeJS"}}]},{"@type":"Organization","@id":"https:\/\/devdojo.co.in\/#organization","name":"DevDojo","description":"Empowering Developers","url":"https:\/\/devdojo.co.in\/"},{"@type":"Person","@id":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/#author","url":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/","name":"Lokendra","image":{"@type":"ImageObject","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/99f102f0cc9080237ce54b91304fd1b3b6fa29925cbaeba93cd796872e58b45c?s=96&d=mm&r=g","width":96,"height":96,"caption":"Lokendra"}},{"@type":"WebPage","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/#webpage","url":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/","name":"Node.js Interview Questions and Answers for Developers","description":"Prepare for your next job with these Node.js interview questions and answers: event loop, async\/await, streams, worker threads and modern Node, with code.","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/devdojo.co.in\/#website"},"breadcrumb":{"@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/#breadcrumblist"},"author":{"@id":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/#author"},"creator":{"@id":"https:\/\/devdojo.co.in\/index.php\/author\/lokendra\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/devdojo.co.in\/wp-content\/uploads\/2026\/10\/nodejs-interview-questions.jpg","@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/#mainImage","width":1200,"height":630,"caption":"Node.js interview questions banner showing the event loop connected to async\/await, streams, workers and modern Node"},"primaryImageOfPage":{"@id":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/#mainImage"},"datePublished":"2026-10-12T13:39:03+00:00","dateModified":"2026-10-12T13:39:03+00:00"},{"@type":"WebSite","@id":"https:\/\/devdojo.co.in\/#website","url":"https:\/\/devdojo.co.in\/","name":"DevDojo","description":"Empowering Developers","inLanguage":"en-US","publisher":{"@id":"https:\/\/devdojo.co.in\/#organization"}}]},"og:locale":"en_US","og:site_name":"DevDojo - Empowering Developers","og:type":"article","og:title":"Node.js Interview Questions and Answers for Developers","og:description":"Prepare for your next job with these Node.js interview questions and answers: event loop, async\/await, streams, worker threads and modern Node, with code.","og:url":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/","article:published_time":"2026-10-12T13:39:03+00:00","article:modified_time":"2026-10-12T13:39:03+00:00","twitter:card":"summary_large_image","twitter:title":"Node.js Interview Questions and Answers for Developers","twitter:description":"Prepare for your next job with these Node.js interview questions and answers: event loop, async\/await, streams, worker threads and modern Node, with code."},"aioseo_meta_data":{"post_id":"195","title":"Node.js Interview Questions and Answers for Developers","description":"Prepare for your next job with these Node.js interview questions and answers: event loop, async\/await, streams, worker threads and modern Node, with code.","keywords":null,"keyphrases":{"focus":{"keyphrase":"Node.js interview questions","score":69},"additional":[]},"primary_term":null,"canonical_url":null,"og_title":"Node.js Interview Questions and Answers for Developers","og_description":"Prepare for your next job with these Node.js interview questions and answers: event loop, async\/await, streams, worker threads and modern Node, with code.","og_object_type":"default","og_image_type":"default","og_image_url":null,"og_image_width":null,"og_image_height":null,"og_image_custom_url":null,"og_image_custom_fields":null,"og_video":"","og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_url":null,"twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"BlogPosting","isEnabled":true},"graphs":[]},"schema_type":"default","schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":"-1","robots_max_videopreview":"-1","robots_max_imagepreview":"large","priority":0,"frequency":"default","local_seo":null,"breadcrumb_settings":null,"limit_modified_date":false,"ai":{"faqs":[],"keyPoints":[],"schemas":[],"titles":[],"descriptions":[],"socialPosts":{"email":{"subject":"","preview":"","content":""},"linkedin":[],"twitter":[],"facebook":[],"instagram":[]}},"created":"2026-10-12 13:30:22","updated":"2026-10-12 13:39:03","focus_keyword":"Node.js interview questions","additional_keywords":null,"truseo_locale":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/devdojo.co.in\/\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/devdojo.co.in\/index.php\/category\/backend\/\" title=\"Backend\">Backend<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/devdojo.co.in\/index.php\/category\/backend\/nodejs\/\" title=\"NodeJS\">NodeJS<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">\u00bb<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tNode.js Interview Questions and Answers: Event Loop, Async and More\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/devdojo.co.in\/"},{"label":"Backend","link":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/"},{"label":"NodeJS","link":"https:\/\/devdojo.co.in\/index.php\/category\/backend\/nodejs\/"},{"label":"Node.js Interview Questions and Answers: Event Loop, Async and More","link":"https:\/\/devdojo.co.in\/index.php\/2026\/10\/12\/nodejs-interview-questions\/"}],"_links":{"self":[{"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/posts\/195","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/comments?post=195"}],"version-history":[{"count":1,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/posts\/195\/revisions"}],"predecessor-version":[{"id":196,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/posts\/195\/revisions\/196"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/media\/194"}],"wp:attachment":[{"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/media?parent=195"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/categories?post=195"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devdojo.co.in\/index.php\/wp-json\/wp\/v2\/tags?post=195"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}