1. Basics of Node.js (25 questions)
Q1. What is Node.js?
Node.js is an open-source, cross-platform runtime environment that lets you run JavaScript code outside a web browser. It is built on Chrome’s V8 JavaScript engine and is mainly used for building fast, scalable server-side applications. Unlike browser JavaScript (which handles UI), Node.js gives access to the file system, network, and other OS features.
Q2. Who created Node.js and when?
Node.js was created by Ryan Dahl in 2009. He wanted to build a system that could handle many concurrent connections efficiently without using threads. It quickly became popular for real-time web apps like chat servers.
Q3. What is the main advantage of using Node.js for backend development?
The biggest advantage is its non-blocking, event-driven I/O model. This allows Node.js to handle thousands of concurrent connections with very little overhead, making it ideal for I/O-heavy apps like APIs, streaming services, or real-time features.
Q4. Is Node.js single-threaded or multi-threaded?
Node.js is single-threaded for JavaScript execution, but it uses a thread pool (libuv) behind the scenes for heavy I/O operations like file reading or DNS lookups. The main thread never blocks, so your code stays responsive.
Q5. What does “non-blocking I/O” mean in Node.js?
Non-blocking I/O means that operations like reading a file or making an HTTP request do not wait (block) for completion. Node.js starts the operation and moves on to other tasks; when the operation finishes, a callback is called. This keeps the server fast and able to serve many users at once.
Q6. How is Node.js different from traditional server-side languages like PHP or Java?
Traditional languages often use multi-threading or blocking I/O, which can be resource-heavy for many connections. Node.js uses a single thread with an event loop and non-blocking I/O, so it uses less memory and scales better for I/O-bound tasks (though CPU-heavy tasks need special handling).
Q7. What is V8 and why is it important for Node.js?
V8 is Google’s open-source JavaScript engine (used in Chrome). Node.js uses V8 to compile and execute JavaScript very quickly into machine code. This makes Node.js performant even though it’s JavaScript.
Q8. What is REPL in Node.js?
REPL stands for Read-Eval-Print-Loop. It is an interactive shell (run by typing node in terminal) where you can write and test JavaScript code line by line. Great for beginners to experiment quickly.
Q9. How do you run a simple Node.js file?
Save your code in a file like app.js, then in terminal run: node app.js. Node will execute the file and show output or start a server.
Q10. What is the role of process object in Node.js?
The global process object gives information about and control over the current Node.js process. You can access environment variables (process.env), exit the process (process.exit()), get arguments (process.argv), or listen to events like uncaught exceptions.
Q11. Explain global object in Node.js.
In Node.js, global is like window in browsers — it holds globally accessible variables and functions (like console, setTimeout, process). You rarely need to use global explicitly because Node attaches many things to it automatically.
Q12. Why is Node.js called “event-driven”?
Node.js reacts to events (like a file finish reading or HTTP request arrives) instead of polling or waiting. You attach listeners to events using .on(), and when the event happens, the callback runs. This model is efficient for real-time apps.
Q13. What are some real-world applications built with Node.js?
Popular examples include Netflix (for fast streaming UI), PayPal (backend APIs), LinkedIn (mobile backend), Uber (real-time matching), and many chat apps. It excels where speed and scalability for I/O matter.
Q14. Is Node.js good for CPU-intensive tasks? Why or why not?
No, because it’s single-threaded — a long CPU task (like heavy math) blocks the event loop and stops other requests. For CPU work, use worker threads, child processes, or offload to another service.
Q15. What is the difference between Node.js and JavaScript in browser?
Browser JavaScript handles DOM, window, fetch (limited). Node.js has no DOM/window, but adds modules like fs, http, path, and full system access. Both use same language syntax but different APIs.
Q16. What does npm stand for and what is it?
NPM means Node Package Manager. It is the default package manager for Node.js — used to install, manage, and share libraries (like Express, lodash). You run commands like npm install express.
Q17. What is package.json and why is it important?
package.json is a file that describes your project: name, version, dependencies, scripts, etc. It lets others (or you later) reinstall exact packages with npm install and run commands like npm start.
Q18. Explain npm init command.
npm init creates a basic package.json file interactively (asks for name, version, description, etc.). Use npm init -y to skip questions and make a default one.
Q19. What is the difference between dependencies and devDependencies?
dependencies are packages your app needs to run in production (like Express). devDependencies are only for development (like testing tools — Jest, nodemon). Install with –save-dev or -D.
Q20. How do you install a package globally in Node.js?
Use npm install -g <package-name> (e.g., npm install -g nodemon). Global packages are available from any folder in terminal, useful for CLI tools.
Q21. What happens when you run npm install without arguments?
It reads package.json and installs all listed dependencies and devDependencies into a node_modules folder. If package-lock.json exists, it uses exact versions from there.
Q22. What is npx and when to use it?
npx lets you run packages without installing them globally (e.g., npx create-react-app my-app). It downloads temporarily if needed, runs, and cleans up — great for one-time tools.
Q23. Why use Node.js for real-time applications?
Its event-driven, non-blocking nature handles many open connections (websockets, polling) efficiently. Libraries like Socket.io make real-time features (chat, live updates) easy and scalable.
Q24. What is the latest major version of Node.js as of early 2026?
As of early 2026, Node.js 20 and 22 are active LTS versions (Long Term Support), with Node.js 23+ in current release. Always check nodejs.org for the latest stable/LTS.
Q25. Can Node.js be used for frontend too?
Indirectly yes — tools like Next.js, Nuxt, or Vite run on Node.js during build/dev. But Node.js itself is server-side; frontend still runs in browser.




