Node.js is a JavaScript runtime for server-side applications. It enables scalable and efficient web development with a vast ecosystem of packages.
Last updated on:- 7th June 2023
1.
What is Node.js ?
A programming language
A web server
A runtime environment
A database management system
Node.js is a runtime environment that allows you to run JavaScript code outside of a web browser, enabling server-side and command-line scripting.
2.
Which of the following is true about Node.js ?
It is single-threaded and uses blocking I/O operations
It is multi-threaded and uses non-blocking I/O operations
It is single-threaded and uses non-blocking I/O operations
It is multi-threaded and uses blocking I/O operations
Node.js is single-threaded and uses non-blocking I/O operations, allowing it to handle concurrent requests efficiently without blocking the execution of other code.
3.
What does NPM stand for ?
Node Project Manager
Node Package Manager
Node Program Manager
Node Plugin Manager
NPM stands for Node Package Manager, which is a package manager for JavaScript libraries and tools. It allows developers to easily install, manage, and publish packages for their Node.js applications.
4.
Which of the following is not a core module in Node.js ?
fs
http
path
ajax
The core modules in Node.js include fs (file system), http (HTTP server), and path (file path handling), but 'ajax' is not a core module.
5.
What is the purpose of the 'require' function in Node.js ?
To include external JavaScript files
To create new modules
To load core modules
To install npm packages
The 'require' function in Node.js is used to load core modules or external JavaScript files by specifying their module name or file path.
6.
Which module in Node.js provides support for working with file systems ?
fs
http
path
util
The 'fs' module in Node.js provides support for working with file systems, including reading and writing files, creating directories, and more.
7.
What is an event emitter in Node.js ?
A function for generating random numbers
A utility module for handling events
A built-in class for creating event-driven applications
A debugging tool for tracking event logs
An event emitter in Node.js is a built-in class that allows you to create event-driven applications by emitting and handling events using the EventEmitter API.
8.
Which of the following is true about streams in Node.js ?
Streams are used for handling HTTP requests
Streams allow you to perform asynchronous file operations
Streams are used for handling database queries
Streams allow you to process data piece by piece
Streams in Node.js allow you to process data piece by piece, which is useful for handling large files or data streams without consuming excessive memory.
9.
What is the purpose of the 'buffer' module in Node.js ?
To store binary data
To encode and decode JSON data
To manipulate strings
To perform encryption and decryption
The 'buffer' module in Node.js provides a way to store and manipulate binary data, such as reading from or writing to sockets, files, or other streams.
10.
What is the role of the 'path' module in Node.js ?
To handle HTTP requests
To create and manipulate file paths
To encode and decode URLs
To perform data validation
The 'path' module in Node.js provides utilities for working with file paths, including resolving, joining, and normalizing paths across different operating systems.
11.
What is the purpose of the 'cluster' module in Node.js ?
To create child processes
To handle HTTP requests
To manage server-side sessions
To perform database operations
The 'cluster' module in Node.js allows you to create child processes, enabling your Node.js application to utilize multiple CPU cores for improved performance.
12.
What is the role of the 'os' module in Node.js ?
To handle HTTP requests
To create and manipulate file paths
To interact with the operating system
To perform data validation
The 'os' module in Node.js provides utilities for interacting with the operating system, such as retrieving information about the system, network interfaces, and more.
13.
What is a middleware in the context of Express.js ?
A module for handling database queries
A function for generating random numbers
A utility module for handling events
Functions that are executed in the request/response pipeline
Middleware in Express.js refers to functions that are executed in the request/response pipeline, allowing you to add additional functionality or modify the request or response objects.
14.
Which programming language is commonly used with Node.js ?
Java
C++
Python
JavaScript
Node.js is commonly used with JavaScript as it provides a runtime environment for executing JavaScript code on the server-side.
15.
What is the purpose of package.json in a Node.js project ?
To manage project dependencies
To define project configuration
To specify project scripts
All of the above
The package.json file in a Node.js project serves multiple purposes. It manages project dependencies, defines project configuration, and specifies project scripts, among other things.
16.
What is the role of the 'jsonwebtoken' library in Node.js ?
To handle HTTP requests
To encode and decode JSON data
To perform encryption and decryption
To manage JSON Web Tokens (JWT)
The 'jsonwebtoken' library in Node.js provides functions for creating, signing, and verifying JSON Web Tokens (JWT), which are used for authentication and authorization purposes.
17.
What is the purpose of the 'bcrypt' library in Node.js ?
To handle HTTP requests
To perform encryption and decryption
To manipulate strings
To create and manipulate file paths
The 'bcrypt' library in Node.js is used for hashing and verifying passwords, providing a secure way to store and compare sensitive information like user passwords.
18.
What is the role of the 'mongoose' library in Node.js ?
To create and manipulate file paths
To handle HTTP requests
To interact with MongoDB databases
To perform data validation
The 'mongoose' library in Node.js provides an object modeling tool for MongoDB, allowing you to define schemas, perform CRUD operations, and more with ease.
19.
What is the global object in Node.js ?
window
global
document
root
In Node.js, the global object is accessible throughout the application and provides global scope. It is analogous to the window object in browser-based JavaScript.
20.
What is an event loop in Node.js ?
A mechanism for handling asynchronous operations
A loop that iterates over an array of events
A function that handles HTTP requests
A data structure for storing events
The event loop in Node.js is a mechanism that handles asynchronous operations. It allows Node.js to perform non-blocking I/O operations and efficiently handle concurrent requests.
21.
What is the purpose of the 'async' library in Node.js ?
To handle HTTP requests
To create and manipulate file paths
To perform asynchronous operations
To perform data validation
The 'async' library in Node.js provides a set of utility functions for handling asynchronous operations, such as running functions in parallel, handling callbacks, and more.
22.
What is the role of the 'lodash' library in Node.js ?
To handle HTTP requests
To create and manipulate file paths
To perform data validation
To provide utility functions for working with data
The 'lodash' library in Node.js provides a collection of utility functions that simplify working with arrays, objects, strings, and more, making data manipulation and transformation easier.
23.
What is the purpose of the 'request' library in Node.js ?
To handle HTTP requests
To create and manipulate file paths
To perform data validation
To handle database operations
The 'request' library in Node.js is used to send HTTP requests to servers and handle the corresponding responses, making it easier to interact with web APIs and services.
24.
What is the purpose of the 'exports' object in Node.js ?
To define variables
To expose functions or objects for use in other modules
To create HTTP servers
To execute JavaScript code
The 'exports' object in Node.js is used to expose functions or objects from a module for use in other modules. It allows you to encapsulate functionality and make it accessible to other parts of your application.
25.
What is the purpose of the 'jsonwebtoken' library in Node.js ?
To handle HTTP requests
To encode and decode JSON data
To perform encryption and decryption
To manage JSON Web Tokens (JWT)
The 'jsonwebtoken' library in Node.js provides functions for creating, signing, and verifying JSON Web Tokens (JWT), which are used for authentication and authorization purposes.
26.
What is the purpose of the 'crypto' module in Node.js ?
To handle HTTP requests
To perform encryption and decryption
To manipulate strings
To create and manipulate file paths
The 'crypto' module in Node.js provides cryptographic functionality, including methods for creating hashes, generating secure random numbers, performing encryption and decryption, and more.
27.
Which module in Node.js is commonly used for working with file system operations ?
http
fs
path
url
The 'fs' module in Node.js provides functionality for working with the file system. It allows you to read, write, and manipulate files and directories.
28.
What is the purpose of the 'dotenv' library in Node.js ?
To handle HTTP requests
To create and manipulate file paths
To perform data validation
To load environment variables from a .env file
The 'dotenv' library in Node.js allows you to load environment variables from a .env file, making it easier to manage configuration options and sensitive information.
29.
What is a buffer in Node.js ?
A temporary storage area for data
A method for error handling
A module for working with streams
A data structure for storing events
A buffer in Node.js is a temporary storage area for data. It is used to store raw binary data and provides methods for manipulating and working with that data.
30.
What is a callback hell in Node.js ?
A situation where callbacks are deeply nested
A performance issue in Node.js
A design pattern for asynchronous programming
A feature of the event loop
Callback hell in Node.js refers to a situation where callbacks are deeply nested, leading to code that is difficult to read and maintain. It can occur when handling multiple asynchronous operations.
31.
What is the purpose of the 'process' object in Node.js ?
To handle HTTP requests
To create child processes
To provide information about the current process
To execute JavaScript code
The 'process' object in Node.js provides information about the current process, such as command-line arguments, environment variables, and process-related events. It allows you to interact with the underlying operating system and control the behavior of your Node.js application.
32.
What is a stream in Node.js ?
A module for working with files
A data structure for storing data
A software component for handling HTTP requests
A sequence of data that is read or written asynchronously
A stream in Node.js is a sequence of data that can be read from or written to asynchronously. It provides an efficient way to handle large amounts of data by processing it in smaller chunks rather than loading it entirely into memory.