In NoSQL databases like MongoDB, how can you ensure data consistency across distributed databases?

  • Use a two-phase commit protocol.
  • Implement eventual consistency.
  • Leverage distributed transactions.
  • Use primary key constraints.
In NoSQL databases, data consistency across distributed databases is typically ensured by implementing eventual consistency. Two-phase commit protocols and distributed transactions can be complex and might introduce performance bottlenecks. Primary key constraints, while important, don't inherently guarantee distributed consistency.

You are creating a real-time chat application in Node.js where you need to broadcast binary data to multiple clients. How would you manage the binary data to ensure optimal performance and minimal memory usage?

  • Use a binary WebSocket library
  • Convert binary data to base64 before transmission
  • Send binary data as raw bytes
  • Serialize binary data as JSON
To ensure optimal performance and minimal memory usage when broadcasting binary data in a real-time chat application, it's best to send binary data as raw bytes. Using a binary WebSocket library or converting to base64 can introduce unnecessary overhead, and serializing binary data as JSON is not efficient.

When importing a module, what is the difference between a relative and absolute path?

  • A relative path specifies the module's location relative to the current file, while an absolute path specifies the module's exact location in the file system.
  • A relative path always begins with a forward slash (/), while an absolute path does not use any slashes.
  • A relative path is used for built-in Node.js modules, while an absolute path is used for third-party modules.
  • A relative path is used for server-side modules, while an absolute path is used for client-side modules.
In Node.js, when importing a module, you can use either a relative path or an absolute path. A relative path specifies the module's location relative to the current file, making it flexible for local module imports. An absolute path, on the other hand, specifies the exact file system path to the module.

What is the significance of the engines field in the package.json file of a Node.js project?

  • It lists the development tools used for the project.
  • It specifies the JavaScript engines that can run the project.
  • It defines the project's build scripts.
  • It lists the project's dependencies.
The engines field in package.json specifies the JavaScript engines and their versions that are compatible with the project. It helps ensure that the project runs correctly on the specified engines and prevents installation on incompatible engines. This is crucial for compatibility and stability.

What is the impact of using JOIN operations on the performance of SQL queries?

  • JOIN operations can improve query performance by reducing the need for multiple queries, but they can also slow down queries if used improperly or on large datasets.
  • JOIN operations have no impact on query performance.
  • JOIN operations always improve query performance.
  • JOIN operations can only be used with small datasets.
JOIN operations can significantly impact query performance. While they can help combine data from multiple tables, they can also introduce complexity and reduce performance if not used efficiently.

To ensure the integrity of uploaded files, it is essential to verify their ______ after they are uploaded.

  • File Hashes
  • Metadata
  • File Size
  • File Type
To ensure the integrity of uploaded files, it is essential to verify their "File Hashes" after they are uploaded. File hashes are cryptographic checksums that can be compared before and after transmission to detect any changes or corruption in the file. Metadata, file size, and file type can provide additional information about the file but do not guarantee its integrity.

Which of the following statements is true regarding JavaScript's symbol data type?

  • Symbols can be used as property keys in objects, but they are not unique.
  • Symbols are always visible in the global scope.
  • Symbols are automatically garbage collected.
  • Symbols are of the same data type as strings.
Symbols in JavaScript can be used as property keys in objects, and they are guaranteed to be unique. This uniqueness makes them useful for defining non-colliding property names.

In Semantic Versioning, what does a caret (^) symbol before a version number, like ^1.2.3, signify in terms of upgrades?

  • It indicates that only bug fixes and patches can be upgraded.
  • It allows upgrades to the specified version and any future backward-compatible versions.
  • It signifies that downgrades are allowed.
  • It prevents any upgrades to the version.
The caret (^) symbol signifies that you can upgrade to the specified version and any future backward-compatible versions, including new features and non-breaking changes.

Which file is created by default when you run the npm init command in a Node.js project?

  • package.json
  • index.js
  • node_modules
  • app.js
When you run npm init in a Node.js project, it creates a package.json file by default. This file is used to manage project dependencies, scripts, and other project-related information. The other options are not created by npm init itself.

What is the primary purpose of the Buffer class in Node.js?

  • To handle HTTP requests
  • To manipulate JavaScript objects
  • To work with binary data
  • To create web pages
The primary purpose of the Buffer class in Node.js is to work with binary data, allowing you to read from or write to streams, interact with file systems, and deal with raw data. It is especially useful in scenarios where you need to work with data in a way that JavaScript's string handling is not suitable, such as when dealing with file I/O or network communication.