WorksheetsNode Js Quizz
Total questions: 20
Worksheet time: 11mins
What is the primary role of the event loop in Node.js?
Handling HTTP requests
Managing asynchronous operations
Synchronizing database queries
Controlling the DOM in the browser
Which of the following is a characteristic of readable streams in Node.js?
They are bidirectional.
They are always in flowing mode.
They emit 'finish' event when data is written.
They cannot be piped.
In Express.js, what is the purpose of the next function in middleware?
It terminates the middleware execution.
It passes control to the next middleware in the stack.
It triggers a route handler.
It sends a response to the client.
Which keyword is used to import modules in CommonJS (Node.js) syntax?
import
use
require
include
In Node.js, what is the purpose of the 'domain' module?
It handles errors in asynchronous operations.
It manages the application's global state.
It isolates error handling for specific parts of the application.
It sets the default error handling behavior.
Scaling and Performance
Distributing tasks to worker threads.
Running multiple instances of the application on different servers.
Optimizing the performance of individual functions.
Managing database connections.
How can you mitigate common security vulnerabilities in a Node.js application?
Regularly update Node.js modules.
Disable error logging.
Use weak passwords for authentication.
Store sensitive information directly in the source code.
Which testing framework is commonly used for Node.js applications?
Mocha
Jest
Jasmine
All of the above
What is the purpose of JWT (JSON Web Tokens) in user authentication?
Storing user passwords securely.
Encoding user information in a compact format.
Verifying the integrity of HTTP requests.
Encrypting communication between the client and server.
Which protocol is commonly used with WebSockets in Node.js?
HTTP
TCP
UDP
SMTP
How can you implement caching in a Node.js application?
Using the localStorage object
Utilizing the cache module
Implementing in-memory caching with tools like Redis
Adding cache headers to HTTP responses
What is CORS, and how can you handle it in a Node.js application?
Cross-Origin Resource Sharing; handled automatically by Node.js
A security feature that prevents cross-site scripting
A mechanism to control which domains can make requests to your server
A Node.js module for handling cross-domain requests
What is GraphQL, and how does it differ from traditional REST APIs?
A query language for APIs with a focus on flexibility and efficiency
A Node.js package for rendering dynamic HTML pages
A security protocol for securing API endpoints
A framework for building real-time applications
How can Docker be beneficial for Node.js applications?
It automatically optimizes Node.js code for better performance
It helps in packaging applications and their dependencies into containers
It replaces the need for package managers like npm
It provides a built-in testing environment for Node.js
What is serverless computing, and how does Node.js fit into serverless architectures?
Serverless computing is a model where applications are run without servers; Node.js is not suitable for serverless
Serverless computing allows running functions without managing servers; Node.js functions can be used in serverless environments
Serverless is a term used for applications without any client-server interaction
Node.js is a serverless framework for building applications without traditional servers
How can Prometheus be used for monitoring a Node.js application?
It is a Node.js module for logging events
Prometheus is not applicable to Node.js applications
Prometheus collects and stores metrics from Node.js applications
It is a built-in feature of the Node.js runtime for tracking errors
What is the purpose of the "payload" in a JSON Web Token (JWT) used for authentication?
It contains the user's password
It is used for digital signature verification
It stores claims about the user
It determines the token's expiration time
How does Express.js facilitate the creation of RESTful APIs in Node.js?
It automatically generates API documentation
It provides routing and middleware features for handling HTTP requests
It enforces strict REST principles, limiting flexibility
Express.js is not suitable for building RESTful APIs
Which library is commonly used for WebSocket communication in Node.js?
What techniques can be used to optimize the performance of a Node.js application?
Minifying JavaScript code and using a Content Delivery Network (CDN)
Increasing the number of blocking synchronous operations
Ignoring code profiling and monitoring
Using a single-threaded approach without clustering
