When using Promise.allSettled, the returned array consists of objects, each having a status property that can either be 'fulfilled' or ________.

  • 'completed'
  • 'resolved'
  • 'rejected'
  • 'done'
When using Promise.allSettled, the status property of each object in the returned array can either be 'fulfilled' or 'rejected,' depending on the outcome of the individual Promises in the input array.

In a Node.js module, properties added to the global object can be accessed from ________.

  • anywhere in the module
  • only within the module
  • any other module
Properties added to the global object in a Node.js module can be accessed from anywhere in the module, making them globally accessible within that module.

What is the significance of test coverage in a codebase, and how does it impact the development process?

  • Test coverage measures the number of lines of code tested; High test coverage guarantees a bug-free codebase; Test coverage is irrelevant for development.
  • Test coverage measures the percentage of code executed by tests; It helps identify untested code paths and potential bugs; High test coverage is a valuable metric but doesn't guarantee bug-free code.
  • Test coverage measures the number of test cases written; High test coverage means exhaustive testing and zero defects; Test coverage should be minimized to save development time.
  • Test coverage is the number of test tools used; High test coverage indicates a comprehensive testing suite; Test coverage depends on project size.
Test coverage measures the percentage of code executed by tests. It helps identify untested code paths, improving code quality. However, it does not guarantee a bug-free codebase, as it depends on the quality of the tests. The other options provide inaccurate definitions or misconceptions about test coverage.

When creating a custom error class in Express.js, it should extend the built-in ______ class.

  • Error
  • HttpException
  • AppError
  • CustomError
When creating a custom error class in Express.js, it should extend the built-in Error class. This allows you to leverage the error handling capabilities provided by JavaScript and Express.js. Extending other classes like HttpException, AppError, or CustomError is not a standard practice for custom error classes in Express.js.

In the http module, the ______ event of the server object is emitted when the server closes.

  • close
  • end
  • disconnect
  • terminate
In the http module, the close event of the server object is emitted when the server closes. This event allows you to perform cleanup or take action when the server is shutting down. The other options (end, disconnect, terminate) do not represent the server closing event in the HTTP module.

What considerations should be made while implementing asynchronous middleware in Express.js?

  • Asynchronous middleware should use the await keyword to ensure proper execution flow.
  • Asynchronous middleware should always return a Promise or use a callback.
  • Asynchronous middleware should not be used in Express.js as it can lead to performance issues.
  • Asynchronous middleware should use the sync keyword to ensure proper execution flow.
When implementing asynchronous middleware in Express.js, it's crucial to ensure that the middleware either returns a Promise or uses a callback to signal when it has completed its work. This is necessary to prevent premature termination of the request-response cycle and maintain proper error handling. Using await is a common approach to handling asynchronous operations.

In case a package should be uninstalled and also removed from the package.json, the ______ command should be executed.

  • npm remove
  • npm uninstall
  • npm erase
  • npm discard
To uninstall a package and also remove it from the package.json file, you should use the npm uninstall (or npm remove) command followed by the package name. This command removes both the package and its reference from package.json. The other options are not used for this specific purpose.

You are tasked with optimizing the build process for a production environment. What considerations should you make regarding the management of dependencies and devDependencies?

  • Include all dependencies in devDependencies
  • Minimize the use of dependencies
  • Exclude devDependencies in production builds
  • Always use the latest version of dependencies
In a production build, it's important to exclude devDependencies as they are typically only needed for development and testing. Including them in production builds can increase the size of the application unnecessarily. Option (2) is a good practice, but not directly related to managing dependencies for production. Option (1) is incorrect as including all dependencies in devDependencies is not a best practice for production builds. Option (4) is risky as it may introduce compatibility issues.

How can you create a buffer instance in Node.js?

  • new Buffer(10)
  • Buffer.alloc(10)
  • createBuffer(10)
  • buffer.create(10)
In Node.js, you can create a buffer instance using the Buffer.alloc(size) method, where size is the desired size of the buffer in bytes. The new Buffer() constructor is deprecated, and the other options are not valid ways to create a buffer in Node.js.

In which scenario is a full-text search most appropriately used?

  • Searching for specific keywords within a large body of text
  • Searching for structured data in a database
  • Searching for filenames in a file system
  • Searching for numerical values in a spreadsheet
Full-text search is most appropriately used when searching for specific keywords within a large body of text, such as searching for documents or articles containing certain words or phrases. It allows for complex text-based queries, making it ideal for content-heavy applications.