The package-lock.json file contains a ______ field that represents the exact installed version of each package.

  • version
  • lock
  • dependencies
  • resolved
The package-lock.json file contains a resolved field that represents the exact installed version of each package. This field specifies the exact URL that was resolved to fetch a particular package version. It is a crucial part of package management in Node.js.

You are working on a large codebase with multiple developers, and you notice inconsistencies in coding styles. How can ESLint help in maintaining a consistent coding style across the project?

  • Manually review and correct code style issues.
  • Create a shared ESLint configuration and enforce it across the project.
  • Ignore coding style issues to avoid conflicts.
  • Encourage developers to use their preferred coding styles.
ESLint can help maintain a consistent coding style by creating a shared ESLint configuration that defines the coding style rules. This configuration can be enforced across the project, ensuring that all developers adhere to the same coding standards. Manually reviewing, ignoring issues, or allowing personal preferences would lead to inconsistencies.

In JavaScript, a closure is created when an inner function accesses the ________ of an outer function after the outer function has executed.

  • parameters
  • variables
  • methods
  • properties
In JavaScript, a closure is created when an inner function accesses the variables of an outer function after the outer function has executed. Closures allow inner functions to "remember" and access the variables of their containing (outer) function even after the outer function has finished executing. This is a fundamental concept for managing scope and data privacy in JavaScript.

You are tasked with developing a real-time chat application where low latency and high availability are critical. Which type of database would be the most suitable, and what considerations should you have in mind regarding data consistency and partitioning?

  • Relational Database
  • NoSQL Database
  • Graph Database
  • In-Memory Database
For a real-time chat application, a NoSQL database would be most suitable due to its ability to handle high concurrency and unstructured data. Considerations for data consistency would involve choosing an appropriate consistency model, like eventual consistency, and partitioning data for scalability and low latency.

How does cache eviction strategy LRU (Least Recently Used) work?

  • LRU removes the item that was accessed most recently.
  • LRU removes the item that was accessed least recently.
  • LRU removes the item with the smallest key.
  • LRU removes items randomly.
LRU (Least Recently Used) eviction strategy removes the item from the cache that was accessed the least recently. This ensures that the cache retains the most recently accessed items, optimizing for cache hits.

Utilizing closures with caution is essential as they can lead to potential memory leaks due to retained ________.

  • Variables
  • Functions
  • References
  • Objects
Closures retain references to their containing scope, which includes variables and functions. If not managed carefully, this can lead to memory leaks as these references may prevent objects from being garbage collected.

How can the process object be used to handle application termination in Node.js?

  • process.exit()
  • process.end()
  • process.terminate()
  • process.halt()
In Node.js, you can use process.exit() to gracefully terminate a Node.js application. It allows you to specify an exit code. The other options, such as process.end(), process.terminate(), and process.halt(), are not valid methods for application termination.

Which of the following is a primary use case for stubbing in tests?

  • Capturing and verifying function calls
  • Simulating the behavior of a function or method
  • Mocking external dependencies
  • Generating random test data
Stubbing in tests is often used to simulate the behavior of a function or method, allowing you to control its responses for testing purposes. It's especially useful when you want to isolate the code under test and ensure that certain functions return specific values or execute specific code paths.

How can you ensure the security of file uploads in a web application?

  • Use an unauthenticated endpoint
  • Limit file size
  • Disallow specific file types
  • Perform server-side validation
To ensure the security of file uploads in a web application, it's crucial to perform server-side validation. This includes checking the file's content type, verifying its size, and possibly scanning it for malware. Other important security measures include limiting file sizes to prevent denial-of-service attacks and disallowing specific file types to prevent the upload of potentially harmful files. Using an unauthenticated endpoint is not recommended as it could lead to security vulnerabilities.

In JavaScript, altering an object’s prototype at runtime can lead to ______ performance impacts.

  • Positive
  • Negative
  • No
  • Minimal
In JavaScript, altering an object's prototype at runtime can lead to "Negative" performance impacts. Modifying prototypes at runtime can cause performance bottlenecks, as it can affect the behavior of all objects that share the same prototype. It's generally recommended to avoid such runtime modifications for performance reasons.