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.

You are developing a Node.js application, and you need to minify your JavaScript files every time before you build your project. Which lifecycle hook would you use to ensure that the minification script runs before the build script every time?

  • prebuild
  • prepublish
  • prestart
  • prerun
In a Node.js project, you would use the prepublish lifecycle hook to ensure that a script runs before the package is published. This hook is commonly used for tasks like minification before publishing to npm. The other options are not standard lifecycle hooks for this purpose.

What happens if an error event is emitted but there is no listener attached to handle it in Node.js?

  • Node.js throws an uncaught exception
  • The error event is silently ignored
  • Node.js logs an error message
  • It depends on the event type
If an error event is emitted in Node.js, but there is no listener attached to handle it, Node.js will throw an uncaught exception. This can lead to the termination of the Node.js process if the exception is not caught elsewhere in your code.

In Node.js, the method buffer.write(string[, offset[, length]][, encoding]) writes the string to the buffer at the specified offset with the specified encoding and returns the number of ______ written.

  • bytes
  • characters
  • bits
  • buffers
The buffer.write method in Node.js writes the string into the buffer as bytes and returns the number of bytes written. It's essential to understand that it deals with bytes, not characters, bits, or other units of data.

In a document-oriented NoSQL database, the ________ defines the structure and data types of the document.

  • Schema
  • Query
  • Index
  • Document Type
In a document-oriented NoSQL database, the "schema" defines the structure and data types of the documents within the database. Unlike traditional relational databases, NoSQL databases like MongoDB are schema-less, but they still rely on a flexible schema to define the structure of documents.

In Express.js, the :id? in a route path like "/users/:id?" denotes that id is a(n) ______ parameter.

  • optional
  • required
  • query
  • body
In Express.js, the :id? in a route path like "/users/:id?" denotes that id is an optional parameter. This means that the id parameter may or may not be present in the URL, and the route will still match. The other options are not correct in this context (required would mean the parameter is mandatory, query is used for query parameters, and body is used for request bodies).

To serve static files such as images, CSS files, and JavaScript files, a special folder called ______ is commonly used in Express.js.

  • public
  • assets
  • static
  • files
To serve static files such as images, CSS files, and JavaScript files, a special folder called the public folder is commonly used in Express.js. This folder typically contains all your publicly accessible static assets.

Which of the following is a property of the Global Object in Node.js?

  • console
  • globalThis
  • module
  • require
In Node.js, the global object is a global context object that contains various properties and methods available throughout the application. globalThis is a reference to the global object, which allows cross-environment compatibility. console, module, and require are not properties of the global object but are commonly used in Node.js for various purposes.

What is the primary difference between OAuth 1.0 and OAuth 2.0?

  • OAuth 1.0 uses HMAC-SHA1 for signing requests, while OAuth 2.0 uses JWT.
  • OAuth 1.0 requires client registration, while OAuth 2.0 does not.
  • OAuth 1.0 uses two-legged authentication, while OAuth 2.0 uses three-legged authentication.
  • OAuth 1.0 is a token-based system, while OAuth 2.0 is a protocol for token-based authentication.
The primary difference is that OAuth 1.0 requires client registration, while OAuth 2.0 does not. OAuth 2.0 introduced a more streamlined and flexible approach to authorization. The other options describe differences but not the primary distinction.

What are Higher-Order components?

  • Components that are used for server-side rendering
  • Components that enhance the behavior of other components
  • Components that render other components
  • Components that use the shouldComponentUpdate() method
Higher-Order components (HOCs) are components that enhance the behavior of other components by adding additional functionality or props. HOCs take a component as input and return a new component that includes the additional behavior. This allows developers to reuse code and separate concerns in their applications.