0% found this document useful (0 votes)
39 views2 pages

NodeJS Questions

The document provides a comprehensive overview of Node.js, covering its definition, features, and operational mechanics. It includes questions and answers on various topics such as npm, the event loop, middleware, and error handling, as well as advanced concepts like the cluster module and CORS. Additionally, it highlights security best practices for Node.js applications.

Uploaded by

Riya Yohannan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views2 pages

NodeJS Questions

The document provides a comprehensive overview of Node.js, covering its definition, features, and operational mechanics. It includes questions and answers on various topics such as npm, the event loop, middleware, and error handling, as well as advanced concepts like the cluster module and CORS. Additionally, it highlights security best practices for Node.js applications.

Uploaded by

Riya Yohannan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Basic Questions

1. What is [Link]?
o [Link] is an open-source, cross-platform JavaScript runtime environment that
executes JavaScript code outside of a web browser. It is designed for building
scalable network applications.
2. What are the main features of [Link]?
o Asynchronous and Event-Driven
o Fast Execution Time
o Single-Threaded but Highly Scalable
o No Buffering
o Cross-Platform Compatibility
3. How does [Link] work?
o [Link] operates on a single-threaded, event-driven architecture that uses non-
blocking I/O calls. This allows it to handle multiple concurrent operations
efficiently.
4. What is npm?
o npm (Node Package Manager) is the default package manager for [Link]. It
allows developers to install, share, and manage dependencies (libraries or
packages) for [Link] projects.
5. What is a callback in [Link]?
o A callback is a function that is passed as an argument to another function and
is executed after some operation has been completed. It is a way to ensure that
certain code runs only after a specific task is finished.

Intermediate Questions

6. What is the event loop in [Link]?


o The event loop is a mechanism that allows [Link] to perform non-blocking
I/O operations. It continuously checks the call stack and the event queue,
executing tasks asynchronously.
7. What are streams in [Link]?
o Streams are objects that allow reading or writing data in a continuous flow.
They are used to handle large amounts of data efficiently. There are four types
of streams: Readable, Writable, Duplex, and Transform.
8. What is middleware in [Link]?
o Middleware functions are functions that have access to the request and
response objects in an application. They can modify the request and response
objects, end the request-response cycle, or call the next middleware function
in the stack.
9. What is the purpose of the [Link] file?
o The [Link] file holds metadata relevant to the project and is used to
manage the project's dependencies, scripts, version, and other configurations.
10. What is [Link]?
o [Link] is a minimal and flexible [Link] web application framework that
provides a robust set of features to develop web and mobile applications. It is
widely used for building APIs and web applications.

Advanced Questions
11. What is the difference between require and import in [Link]?
o require is used in CommonJS modules, while import is used in ES6
modules. require is synchronous and can be used anywhere in the code,
whereas import is asynchronous and can only be used at the top of the file.
12. How do you handle asynchronous operations in [Link]?
o Asynchronous operations in [Link] can be handled using callbacks, promises,
and async/await.
13. What is the cluster module in [Link]?
o The cluster module allows you to create child processes (workers) that share
the same server port. This helps in taking advantage of multi-core systems and
handling more requests.
14. What is a buffer in [Link]?
o A buffer is a temporary storage area for a fixed amount of data. In [Link],
buffers are used to handle binary data read from files or received from
network streams.
15. How does [Link] handle child processes?
o [Link] provides the child_process module to create and control child
processes. You can use methods like spawn, exec, execFile, and fork to
handle child processes.

Miscellaneous Questions

16. What is the difference between [Link]() and setImmediate()?


o [Link]() schedules a callback function to be invoked in the next
iteration of the event loop, before any I/O operations. setImmediate()
schedules a callback to be executed after the current poll phase.
17. What are some common built-in modules in [Link]?
o fs (File System)
o http (HTTP server and client)
o path (File and directory paths)
o os (Operating system information)
o url (URL resolution and parsing)
18. How do you handle errors in [Link]?
o Errors in [Link] can be handled using try-catch blocks, the error event, and
error-handling middleware in Express.
19. What is CORS and how do you handle it in [Link]?
o CORS (Cross-Origin Resource Sharing) is a mechanism that allows resources
on a web server to be requested from another domain. In [Link], you can
handle CORS using the cors middleware in an Express application.
20. What are some security best practices for [Link] applications?
o Validate and sanitize user inputs
o Use HTTPS
o Implement proper error handling
o Use environment variables for sensitive information
o Regularly update dependencies

You might also like