Functions that perform HTTP requests are not considered pure because they _________.

  • Use Arrow Functions
  • Have Side Effects
  • Are Asynchronous
  • Are Synchronous
Functions that perform HTTP requests are not considered pure because they have side effects. Purity in functions means that they do not cause any observable side effects, and HTTP requests involve external actions that can impact the program's state.

When a const variable is declared in a block scope, what is the scope of this variable?

  • Local to the block
  • Global
  • Function-level
  • Lexical scope
In JavaScript, when you declare a constant variable (const) inside a block (like an if statement or a loop), the scope of that variable is limited to the block. This means it cannot be accessed outside of that block.

If a project is using a third-party library with multiple components, but only a few are needed, how can tree shaking be utilized for efficiency?

  • Import only the needed components from the library in the code.
  • Include the entire library as is.
  • Manually remove unused components from the library.
  • Use a separate smaller library for the required components.
Tree shaking can be leveraged by importing only the necessary components from the third-party library. This way, the bundler can exclude the unused parts during the build process, optimizing the bundle size. The other options are not efficient for tree shaking purposes.

When you need to execute a function on an array and need the result to be a single output value, use _________.

  • map
  • forEach
  • reduce
  • filter
The reduce method is used to execute a reducer function on each element of the array, resulting in a single output value.

Dynamic imports are especially useful for __________ loading of modules.

  • Asynchronous
  • Synchronous
  • Sequential
  • Parallel
Dynamic imports are especially useful for asynchronous loading of modules. Unlike traditional synchronous imports, dynamic imports allow modules to be loaded asynchronously, enabling the application to continue executing code without waiting for the module to be fully loaded. This asynchronous behavior is beneficial for optimizing performance, especially in scenarios where certain modules are only needed under specific conditions. Understanding the advantages of asynchronous module loading is crucial for developing efficient and responsive JavaScript applications.

When using mixins in ES6, the mixin's methods can conflict with the _________ of the target class.

  • Methods
  • Properties
  • Constructors
  • Inheritance
The correct option is Properties. When using mixins in ES6, there can be conflicts between the properties of the mixin and the target class. It's important to handle these conflicts appropriately to ensure the correct behavior of the composed object.

A variable declared with let can be redeclared in a different __________ but not in the same scope.

  • block
  • function
  • module
  • statement
The correct option is 'block'. In JavaScript, a variable declared with 'let' has block-level scope. This means it can be redeclared within a different block, such as within a different if statement or loop. However, attempting to redeclare it in the same block or scope will result in an error.

A for...of loop is best suited for iterating over ________ data structures, like arrays and strings.

  • asynchronous
  • asymmetric
  • iterable
  • immutable
The for...of loop is designed for iterating over iterable data structures, such as arrays and strings. It simplifies the process of iterating over the values without the need for index management.

Consider a scenario where you have an array of numbers, and you need to create a new array with only the numbers greater than 10. Which method would you use?

  • filter
  • map
  • reduce
  • forEach
In this scenario, the most suitable array method is filter. The filter method is designed for creating a new array containing elements that pass a certain condition. It allows you to filter out numbers greater than 10 effectively.

If you have a Symbol mySymbol, you can access its description using mySymbol.__________.

  • name
  • description
  • valueOf
  • toString
The correct property to access the description of a Symbol is description. The description property is used to get or set the description of a Symbol, providing additional information about the Symbol.