Which of the following array methods does not mutate the original array in JavaScript?

  • splice()
  • push()
  • concat()
  • pop()
The concat() method in JavaScript creates a new array that combines the elements of the original array and the elements passed as arguments, without modifying the original array. The other methods, such as splice(), push(), and pop(), directly modify the original array.

The fs.createReadStream method is particularly useful when dealing with ______ sized files.

  • small
  • large
  • binary
  • text
The fs.createReadStream method in Node.js is particularly useful when dealing with large sized files. This method allows you to efficiently read large files in smaller chunks, which can be memory-efficient for handling large datasets.

What happens to the Event Loop when the callback queue and the task queue are both not empty?

  • It suspends the Event Loop until both queues are empty.
  • It processes callbacks from the callback queue before tasks from the task queue.
  • It processes tasks from the task queue before callbacks from the callback queue.
  • It randomly selects items to process from both queues.
When both the callback queue and the task queue are not empty, the Event Loop in Node.js follows a specific order. It first processes callbacks from the callback queue before moving to tasks from the task queue. This order ensures that callback functions, which often include I/O operations, are handled promptly.

In JavaScript, a function that is defined inside another function has access to the outer function's variables, forming a ________.

  • Closure
  • Enclosure
  • Junction
  • Intersection
In JavaScript, when a function is defined inside another function, it forms a "closure." A closure allows the inner function to access the outer function's variables even after the outer function has finished executing.

You are designing a system with heavy Read and Update operations on the database. Which database design strategy would you adopt to balance the load and ensure data consistency?

  • Sharding
  • Replication
  • Denormalization
  • Indexing
In a scenario with heavy Read and Update operations, sharding is a database design strategy where you distribute the data across multiple servers or nodes. This helps balance the load and improve Read performance. Sharding ensures data consistency by managing data distribution and replication across shards. Replication (Option 2) can improve Read performance but doesn't address balancing the load directly. Denormalization (Option 3) can help with Reads but may complicate data consistency. Indexing (Option 4) helps with Read performance but doesn't balance the load.

Which of the following is true regarding object keys in JavaScript?

  • Object keys must be unique within an object.
  • Object keys can only be of type string.
  • Object keys are case-sensitive.
  • Object keys can only be integers.
Object keys in JavaScript are case-sensitive. This means that keys with different letter casing (e.g., 'key' and 'Key') are considered distinct in an object. The other options do not accurately describe the behavior of object keys.

How can the async/await syntax be used with error handling mechanisms, like try/catch, to handle asynchronous errors?

  • Wrap the entire async function body in a try/catch block
  • Use await inside a try/catch block for each individual asynchronous operation
  • Use async without try/catch for handling errors
  • Use await without try/catch for handling errors
To handle asynchronous errors with async/await, you should use a try/catch block around each individual await operation. This allows you to catch and handle errors for specific asynchronous operations within the async function. Option A would catch errors for the entire function, which might not provide fine-grained error handling. Options C and D are incorrect approaches for error handling with async/await.

What will happen if there are conflicting names when importing items from a module?

  • The last imported item with the conflicting name will override the previous ones.
  • An error will occur, and you will need to manually resolve the conflict by renaming the items.
  • JavaScript will automatically assign unique names to the conflicting items.
  • Conflicting names are not allowed when importing items from a module.
In JavaScript, when you import items from a module, if there are conflicting names (e.g., two imported items have the same name), the last imported item with the conflicting name will override the previous ones. This can lead to unexpected behavior and should be avoided by using unique and descriptive names for imported items.

To run a pre-hook for a custom script named "build," you would define a script named ______ in your package.json file.

  • prebuild
  • pre-hook
  • beforebuild
  • pre-build
To run a pre-hook for a custom script named "build" in your package.json file, you would define a script named prebuild. This allows you to execute tasks before the "build" script is run, such as setting up dependencies or configurations. The other options do not follow the standard naming convention for npm pre-hooks.

What is the purpose of the res.send() method in Express?

  • To send a response to the client
  • To receive data from the client
  • To redirect the client to another route
  • To render a view template
The res.send() method in Express is used to send a response back to the client. It is commonly used to send text, HTML, JSON, or other data as the response to an HTTP request. It is a fundamental method for responding to client requests in Express applications. The other options are not the primary purpose of res.send().