How can you destructure nested properties in objects using JavaScript?

  • const { prop1.prop2 } = myObject;
  • const { prop1: { prop2 } } = myObject;
  • const [ prop1, prop2 ] = myObject;
  • const { prop1[prop2] } = myObject;
To destructure nested properties in JavaScript objects, you should use the syntax in Option 2. It allows you to access nested properties within myObject. The other options either contain incorrect syntax or won't work for this purpose.

In what scenarios would you implement custom middleware instead of using built-in middleware in Express.js?

  • Custom middleware should always be avoided, and built-in middleware should be used.
  • Custom middleware is necessary when working with database connections.
  • Custom middleware should be used when you need to perform application-specific logic that isn't covered by built-in middleware.
  • Custom middleware is used only for unit testing purposes.
Custom middleware is implemented in Express.js when you have specific application logic that cannot be handled by built-in middleware. Common scenarios include authentication, request logging, data validation, and handling application-specific errors. Built-in middleware covers common use cases, but custom middleware allows you to tailor the middleware pipeline to your application's unique needs.

How does normalizing database tables impact the Read and Update operations in CRUD?

  • Improves Read performance, may complicate Updates
  • Improves Update performance, may slow down Reads
  • Has no impact on either Read or Update operations
  • Improves both Read and Update operations
Normalizing database tables often improves Read performance by reducing data redundancy. However, it may complicate Update operations since data may be spread across multiple tables, requiring joins. Option 2 is not generally true as normalization tends to have a positive impact on Update operations. Option 4 is an oversimplification.

What does the resolve function do in a JavaScript Promise?

  • It is called when an error occurs.
  • It is called when the Promise is rejected.
  • It is called when the Promise is fulfilled with a value.
  • It is called to cancel the Promise.
The resolve function in a JavaScript Promise is called when the Promise is fulfilled successfully with a value. It signifies that the asynchronous operation inside the Promise has completed successfully, and the value provided in the resolve function is the result.

What is the output of the following code snippet: console.log(1 == '1')?

  • TRUE
  • FALSE
  • undefined
The output of the code snippet is true. In JavaScript, the == operator performs type coercion, so it converts the string '1' to a number before comparing, and 1 is equal to 1.

In what scenario would a package be listed in both dependencies and devDependencies?

  • When the package is a development tool
  • When it's a runtime dependency
  • When it's a peer dependency
  • When it's a transitive dependency
A package can be listed in both dependencies and devDependencies when it's a development tool that is needed during both development and runtime. An example might be a testing library or build tool.

What is the primary use of Streams in Node.js?

  • Managing database connections
  • Handling HTTP requests and responses
  • Storing configuration data
  • Sorting arrays
The primary use of Streams in Node.js is for handling data in a streaming fashion, especially for reading and writing data efficiently. They are commonly used for handling HTTP requests and responses, file I/O, and more, where data can be processed in smaller chunks without loading the entire dataset into memory.

The ______ header is often used to pass the authentication token from the client to the server in HTTP requests.

  • Authorization
  • Token
  • Authentication
  • Bearer
The Bearer header is often used to pass the authentication token from the client to the server in HTTP requests when using JWTs for authentication. It is a common practice to include the JWT as a Bearer token in the Authorization header. The other options may not be standard headers for this purpose.

The typeof operator in JavaScript returns 'object' for ________.

  • null
  • undefined
  • arrays
  • functions
In JavaScript, the typeof operator returns 'object' when used with the value null. This can be a source of confusion because null is not actually an object; it's a primitive value with its own data type.

Named imports in JavaScript must match the exported names in the module, unless they are ________.

  • Renamed
  • Aliased
  • Excluded
  • Deprecated
Named imports in JavaScript must match the exported names in the module, unless they are "aliased." When you alias an import, you can give it a different name than the exported name, providing flexibility in your code.