Using yield* within a generator function delegates to another _________ or iterable object.

  • Generator
  • Function
  • Object
  • Array
In JavaScript, the yield* statement is used within a generator function to delegate to another generator or iterable object. The yield* expression iterates over the provided iterable, effectively delegating to each element's value.

A rejected promise will skip all subsequent .then() methods until a _________ method is found.

  • finally()
  • catch()
  • reject()
  • resolve()
The correct method is catch(). When a Promise is rejected, it will skip all subsequent then() methods and look for a catch() method in the chain to handle the rejection. The catch() method is used to specify what to do in case of a rejected Promise.

What is the behavior of await in a loop when iterating over a set of asynchronous tasks?

  • Pauses the loop until the asynchronous task is complete
  • Skips the iteration with the unresolved promise
  • Throws an error
  • Continues the loop without waiting
When using await in a loop, it pauses the execution of the loop until the asynchronous task is complete. This ensures that the subsequent iterations don't start until the current one finishes. This behavior is crucial to avoid race conditions and maintain the desired order of execution in asynchronous operations.

What is a use case for choosing WeakMap over Map?

  • When the keys need to be weakly held and automatically removed
  • When the keys have a strong reference and need to be retained
  • When the map needs to be iterated in a predictable order
  • When the map requires frequent updates
A use case for choosing WeakMap over Map is when the keys need to be weakly held and automatically removed when they are no longer referenced elsewhere in the code. This is beneficial for scenarios where precise memory management is crucial.

When applied to a string, the spread operator will split it into individual '__________'.

  • Characters
  • Substrings
  • Arrays
  • Elements
When applied to a string, the spread operator (...) will split it into individual characters, creating an array of characters. This is useful for tasks where you need to manipulate individual characters in a string or convert a string into an array of characters.

How does the yield keyword function in the context of iterators and iterables?

  • Pauses the execution and returns a value to the iterator
  • Ends the iterator immediately
  • Skips the next iteration
  • Continues the execution without interruption
In the context of iterators and iterables, the yield keyword is used to pause the execution of a generator function, returning a value to the iterator. When the generator is later called again, it resumes execution from where it was paused.

How can you handle potential undefined values when destructuring an object?

  • Ignore the value
  • Provide default values
  • Throw an error
  • Use try-catch block
When destructuring an object, you can provide default values to handle potential undefined values. If the property is not present in the object, the default value will be used. This helps prevent errors due to missing properties.

Can a for...of loop be used to iterate over a generator function's yielded values?

  • Yes, a for...of loop can iterate over the yielded values of a generator function.
  • No, for...of loops are not compatible with generator functions.
  • Yes, but it requires additional syntax.
  • No, generator functions can only be iterated using for...in loops.
Yes, a for...of loop can be used to iterate over a generator function's yielded values. The for...of loop automatically iterates over the values yielded by the generator, making it a convenient and readable way to consume generator values.

In ES6, class properties are often initialized inside the ________ method.

  • initialize
  • constructor
  • create
  • new
Class properties in ES6 are commonly initialized inside the constructor method. This allows you to set initial values for properties when an object is created.

Default parameters can be combined with object destructuring to construct complex default values.

  • Object Literals
  • Object Destructuring
  • Object Prototypes
  • Object Methods
ES6 introduced object destructuring, allowing you to extract values from objects easily. When combined with default parameters, it becomes a powerful feature for defining functions with complex default values. The correct option, "Object Destructuring," signifies this technique.