You are tasked with implementing an authentication system for your Express API. What considerations should you make regarding security, user experience, and scalability when choosing an authentication strategy?

  • Use JWT (JSON Web Tokens) with long expiration times.
  • Store plain text passwords in the database.
  • Implement OAuth 2.0 for social login only.
  • Use basic authentication over HTTP.
Using JWT with long expiration times might seem like a convenient option for user experience, but it could pose a security risk. Storing plain text passwords is a severe security vulnerability. Implementing OAuth 2.0 for social login only might not be sufficient for all authentication needs. Using basic authentication over HTTP is not secure. A robust authentication strategy should consider security (option 1) without compromising user experience and

To perform an action once a Promise is settled, regardless of its outcome, you can use the .finally() method, which is called on the ________ of a Promise.

  • rejection
  • resolution
  • completion
  • termination
To perform an action once a Promise is settled, regardless of whether it's fulfilled or rejected, you can use the .finally() method. This method is called on the "completion" of a Promise. It's often used for cleanup operations.

In Node.js, how can data be written to a writable stream?

  • Using the read() method
  • Using the write() method
  • Using the pipe() method
  • Using the readable() method
Data can be written to a writable stream in Node.js using the write() method. This method allows you to write data to the stream, which can be a file, network connection, or any other writable destination. The pipe() method is used for piping data from a readable stream to a writable stream, and the other options are not the correct ways to write data to a writable stream.

When implementing indexing, what factors should be considered to mitigate the impact on database write performance?

  • Selective indexing
  • Index maintenance strategy
  • Using index-only scans
  • Increasing index size
When implementing indexing, factors to consider for mitigating the impact on write performance include selective indexing (indexing only the columns that are frequently queried), choosing an appropriate index maintenance strategy (e.g., periodic maintenance rather than immediate updates), and using index-only scans to reduce disk I/O during reads. Increasing the index size can have a negative impact on write performance, so it should be done judiciously.

Which command is used to install a Node.js package globally?

  • npm global install
  • npm i -g
  • npm install -g
  • npm add -g
To install a Node.js package globally, you should use the npm install -g command. This makes the package available for use across different projects. The other options may not work as expected or are not the recommended way to install packages globally.

To override ESLint rules for specific files or directories, you can create a .eslintignore or ______ file with the patterns of the files or directories to be excluded.

  • .eslintrc.js
  • .eslintignore
  • .eslintconfig
  • .eslintexclude
To override ESLint rules for specific files or directories, you can create a .eslintignore file with patterns of the files or directories to be excluded from ESLint linting. The other options are not used for this purpose.

Which of the following events is emitted when data is available to read from a readable stream?

  • data
  • readable
  • onData
  • available
In Node.js, the 'data' event is emitted when data is available to read from a readable stream. This event allows you to consume the data as it becomes available. The other options are not standard events for this purpose.

In a sharded database architecture, how are Update operations handled across multiple shards?

  • Updates are broadcast to all shards
  • A central coordinator handles all updates
  • Each shard independently handles updates for its data
  • Updates are queued and processed sequentially
In a sharded database architecture, a central coordinator (Option 2) often handles updates that affect multiple shards. Each shard (Option 3) independently handles updates for its own data, but coordinated updates across shards typically require a central component. Options 1 and 4 are not common methods for handling updates in sharded databases.

While working on a project, you are required to extract specific properties from objects and assign them to variables. How would you utilize destructuring assignment to efficiently accomplish this task, and what would you do to handle non-existent properties?

  • const { prop1, prop2 } = sourceObject;
  • const [prop1, prop2] = sourceObject;
  • const { prop1, prop2 } = [sourceObject];
  • const [prop1, prop2] = { ...sourceObject };
To efficiently extract specific properties from objects using destructuring assignment in JavaScript, you would use the syntax const { prop1, prop2 } = sourceObject;. This assigns the values of prop1 and prop2 from sourceObject to the corresponding variables. To handle non-existent properties, you can provide default values like const { prop1 = defaultValue1, prop2 = defaultValue2 } = sourceObject;. The other options are not correct ways to achieve this task.

A ______ cache stores data in a shared location that can be accessed by multiple application instances.

  • Shared
  • Distributed
  • Local
  • In-Memory
A Distributed cache stores data in a shared location that can be accessed by multiple application instances. This allows multiple nodes of an application to share cached data, improving performance and reducing redundancy.

Which of the following stream types is used for reading data in Node.js?

  • Writable Stream
  • Readable Stream
  • Duplex Stream
  • Transform Stream
Readable Streams are used for reading data in Node.js. They allow you to read data from various sources, such as files, HTTP requests, and more, in a non-blocking and efficient manner.

What is the primary difference between null and undefined in JavaScript?

  • null represents an intentional absence of any value, while undefined indicates a variable has been declared but has not been assigned a value.
  • null represents a numeric value of zero, while undefined represents an empty string.
  • null is used for variables that are out of scope, while undefined is used for variables with no value.
  • null is a boolean value, while undefined is a number.
In JavaScript, null represents the intentional absence of any value, while undefined indicates that a variable has been declared but has not been assigned a value. Understanding this difference is crucial for handling data in JavaScript effectively.