What is the significance of the 'Agent' class in the http module of Node.js?

  • The Agent class manages and optimizes the use of persistent connections for HTTP/HTTPS requests.
  • The Agent class is used to create new HTTP request objects.
  • The Agent class is used for authentication in HTTP requests.
  • The Agent class is used for handling HTTP response headers.
The 'Agent' class in the http module of Node.js is significant because it manages and optimizes the use of persistent connections for HTTP/HTTPS requests. This helps improve performance by reusing connections for multiple requests.

How does JavaScript’s class syntax relate to prototypal inheritance?

  • JavaScript classes are a syntactical sugar on top of prototypal inheritance
  • JavaScript classes are a replacement for prototypal inheritance
  • JavaScript classes are unrelated to prototypal inheritance
  • JavaScript classes are an extension of the Object prototype
JavaScript's class syntax is essentially syntactical sugar built on top of prototypal inheritance. Under the hood, classes in JavaScript still use prototypes to achieve inheritance and object creation. They provide a more familiar and structured way to work with prototypes.

To use a shared ESLint configuration across multiple projects, you can create a ______ package that includes the shared ESLint configuration.

  • config
  • eslint
  • share
  • linter
To use a shared ESLint configuration across multiple projects, you can create an eslint package that includes the shared ESLint configuration. This allows you to maintain a consistent linting configuration across projects.

The const keyword in JavaScript is used to declare variables whose values are not supposed to be ________.

  • modified
  • read
  • changed
The const keyword in JavaScript is used to declare variables whose values are not supposed to be changed or reassigned after they are initially set. It creates a constant reference to a value, making the variable immutable.

You are initializing a new Node.js project and want to set up a private repository. How would you ensure that your project's package.json file is correctly configured to reflect this?

  • Edit the package.json file and add a "repository" field with the URL of your private repository.
  • Run a command like npm setup-repo to automatically configure the package.json file.
  • Use a separate config.json file to specify the repository details.
  • Add a comment in the README.md file with the repository information.
To correctly configure your project's package.json file for a private repository, you should add a "repository" field with the URL of your private repository. This allows others to find your code in the specified repository. The other options do not follow the standard practice for configuring the repository.

To prevent accidental overwriting, the NPM registry does not allow republishing of any package version that has been ________.

  • tagged
  • unpublished
  • locked
  • archived
he NPM registry does not allow republishing of any package version that has been unpublished. Once a version is unpublished, it cannot be re-published to avoid potential issues with accidental overwriting.

You are building a high-performance API in Node.js, and you need to implement long-running computations without blocking incoming requests. How would you leverage the Event Loop and Non-Blocking I/O to achieve this?

  • Use setTimeout for long-running computations.
  • Offload computations to a separate thread using worker_threads.
  • Block the Event Loop until computations are complete.
  • Use synchronous I/O for improved performance.
To implement long-running computations without blocking incoming requests in Node.js, you should use worker_threads to offload the CPU-intensive tasks to separate threads, allowing the Event Loop to remain responsive. Options a, c, and d are not recommended because they involve blocking or potentially blocking the Event Loop, which can lead to poor performance and unresponsiveness.

When is the package-lock.json file created or updated in a Node.js project?

  • It is created when the project is started and never updated
  • It is created when dependencies are installed or updated using npm
  • It is automatically created when the project is pushed to a version control system
  • It is manually created by the developer when needed
The package-lock.json file is created or updated in a Node.js project when dependencies are installed or updated using npm (Node Package Manager). This file keeps track of the specific versions of dependencies currently used in the project. It is automatically generated and updated to reflect changes in the project's dependencies. The other options are not accurate; it's not created when the project is started, it's not automatically created when pushed to version control, and it's not manually created by developers for typical use cases.

The process of an object gaining access to properties and methods of another object through the prototype chain is known as ______.

  • Inheritance
  • Encapsulation
  • Polymorphism
  • Abstraction
The process of an object gaining access to properties and methods of another object through the prototype chain is known as "Inheritance." In JavaScript, objects inherit properties and methods from their prototypes in a chain-like fashion. This allows for code reuse and is a fundamental concept in object-oriented programming.

Which of the following is a common tool used for benchmarking Node.js applications?

  • NPM
  • Mongoose
  • Apache
  • Apache Benchmark (ab)
Apache Benchmark (ab) is a common tool used for benchmarking Node.js applications. It allows you to measure the performance and concurrency of your Node.js server by simulating multiple requests. NPM and Mongoose are not benchmarking tools, and Apache is not typically used for Node.js benchmarking.

Which of the following JavaScript properties allows an object to inherit properties from another object?

  • inherit
  • copy
  • prototype
  • extend
In JavaScript, the prototype property is used to allow an object to inherit properties from another object. When an object is created, it inherits properties and methods from its prototype, which can be another object. This forms the basis of prototype-based inheritance in JavaScript. The other options are not standard properties used for inheritance.

How can a Refresh Token be utilized effectively in maintaining user sessions securely in a web application?

  • A refresh token can be used to generate new access tokens without requiring the user to re-enter their credentials.
  • A refresh token can be used to store user session data on the client-side.
  • A refresh token can be used as the primary authentication method for users.
  • A refresh token can be shared publicly without security concerns.
A refresh token is a long-lived token that can be used to obtain a new access token after the previous one expires. It should be kept secret and securely stored on the client side. It enhances security by reducing the need to store access tokens, which have shorter lifespans, on the client.