Which data type in JavaScript can be used to store a sequence of characters?

  • char
  • sequence
  • string
  • text
In JavaScript, the string data type is used to store a sequence of characters. The char data type doesn't exist in JavaScript, and neither sequence nor text are valid data types for this purpose.

When an error occurs in Node.js, the error object is typically an instance of __________.

  • Error
  • Exception
  • ErrorObject
  • Err
In Node.js, when an error occurs, the error object is typically an instance of the built-in Error object. This object contains valuable information about the error, such as a message and a stack trace.

What is the role of the extends property in an ESLint configuration file?

  • It specifies the file extensions to be linted.
  • It extends the code editor with ESLint features.
  • It defines the list of plugins to use.
  • It inherits configurations from other configurations.
The extends property in an ESLint configuration file allows you to inherit configurations from other configurations. It's a way to reuse or build upon existing ESLint configurations, making it easier to enforce consistent coding standards across projects.

You are building a game where a player must answer a series of questions. How would you structure the control flow to handle the player’s responses and determine the next action or question based on the response?

  • if...else if...else statements
  • switch statement
  • try...catch statements
  • while loop
To handle the player's responses and determine the next action or question based on the response in a game, you would typically use a series of if...else if...else statements. These conditional statements allow you to evaluate multiple conditions and execute corresponding code blocks based on the player's response. The switch statement can also be used, but it's better suited for cases where you need to match a single value to multiple possible cases. try...catch is used for error handling, and a while loop is generally not suitable for handling player responses in this context.

To handle uncaught exceptions in a Node.js application, you can use process.on('______', callback).

  • unhandledRejection
  • process.error
  • exception
In Node.js, you can handle uncaught exceptions by using the process.on('unhandledRejection', callback) event. This allows you to capture unhandled promise rejections and take appropriate actions.

You are managing a project with multiple dependencies, and you want to ensure that upgrading a dependency doesn't break the project due to API changes. How would you specify the version numbers of the dependencies in the package.json file?

  • ^1.0.0
  • ~1.0.0
  • 1.0.0
  • 1.x.x
To ensure that only patch-level changes are allowed for your dependencies, you should use the ~ (tilde) prefix. This will allow for bug fixes (patch versions) but prevent breaking changes (minor or major versions).

The 'highWaterMark' option in Node.js streams denotes the ______ of the internal buffer.

  • size
  • rate
  • capacity
  • length
In Node.js streams, the 'highWaterMark' option denotes the capacity of the internal buffer. This value determines how much data the stream can buffer before it starts to pause the data source.

In what way does the Event Loop affect the performance of a Node.js application?

  • It can improve performance by handling asynchronous operations efficiently.
  • It slows down the application by blocking all I/O operations.
  • It has no impact on performance.
  • It can only handle synchronous operations.
The Event Loop in Node.js plays a crucial role in improving performance by efficiently handling asynchronous operations. It allows Node.js to execute non-blocking code, ensuring that the application remains responsive and can handle multiple concurrent requests without getting blocked.

Which of the following is the primary role of middleware in Express.js?

  • Handling client-side routing
  • Handling server-side routing
  • Managing HTTP requests and responses
  • Creating database schemas
The primary role of middleware in Express.js is to manage HTTP requests and responses. Middleware functions are executed in the order they are defined in the Express application and can perform various tasks such as authentication, logging, and modifying request/response objects. They play a crucial role in the request/response cycle.

Which keyword is used to export multiple things from a module in JavaScript?

  • import
  • export
  • require
  • module
In JavaScript, the export keyword is used to export multiple things from a module. It allows you to specify which functions, objects, or variables should be accessible from outside the module. The import keyword is used for importing from modules, not exporting. The require and module keywords are used in CommonJS, a different module system.