What is the base case in a recursive function?

  • The initial condition
  • The stopping condition
  • The recursive condition
  • The iterative condition
In a recursive function, the base case is the condition that prevents further recursion. It is crucial for stopping the recursion and ensuring that the function does not enter an infinite loop.

In ES6, what is the behavior of using super in a method when extending a class?

  • Calls the superclass constructor
  • References the superclass prototype
  • Creates a new instance of the superclass
  • Invokes the superclass method
In ES6, when using super in a method of a subclass, it refers to the superclass, allowing access to its methods and properties. It is often used to call the superclass constructor using super() or invoke methods on the superclass. This facilitates extending the functionality of the superclass.

For side effects only, without importing any variables, use import _________ from 'module-name'.

  • { sideEffect }
  • sideEffect
  • * as sideEffect
  • sideEffect as default
In this scenario, the correct option is c) * as sideEffect. This syntax allows importing all exports from the 'module-name' without explicitly naming them.

One primary difference between WeakMap and Map is that WeakMap keys are ________ to garbage collection.

  • Referenced
  • Immutable
  • Strongly bound
  • Weakly bound
In a WeakMap, the keys are weakly held, meaning that they don't prevent the referenced objects from being garbage collected. This is particularly useful when using objects as keys, as it allows them to be garbage collected when they are no longer needed.

When a generator function is called, what is returned?

  • Generator object
  • Array
  • Promise
  • String
When a generator function is called, it returns a Generator object. This object can be used to control the execution of the generator using methods like next(). Options b), c), and d) are incorrect as they do not represent the result of calling a generator function.

Which method is used to access the properties of an object's prototype?

  • Object.prototype.get()
  • Object.keys()
  • Object.prototype.getProperty()
  • Object.getOwnPropertyNames()
To access the properties of an object's prototype, the Object.keys() method is commonly used. It returns an array of a given object's property names, including properties inherited from its prototype chain.

How does the spread operator assist in merging and overriding properties of multiple objects?

  • It creates a shallow copy of the objects and combines their properties.
  • It performs a deep merge of the objects' properties.
  • It only merges properties at the top level of the objects.
  • It only works with objects of the same type.
The spread operator creates a shallow copy of the objects, meaning it only copies the top-level properties. It assists in merging by combining these properties, but it does not perform a deep merge of nested properties.

Consider a scenario where you are integrating third-party APIs in a web application. How would you ensure that API failures do not crash your application?

  • Implementing robust error handling, logging, and potentially using circuit breakers
  • Ignoring API errors and allowing the application to continue execution
  • Restarting the application upon API failure
  • Redirecting users to a generic error page on any API failure
Ensuring the resilience of the application against API failures involves implementing robust error handling mechanisms. This includes catching and logging errors, implementing retry strategies, and potentially using circuit breakers to temporarily halt requests in the event of persistent failures. Ignoring errors or restarting the application can lead to a degraded user experience and make troubleshooting difficult.

A common use case for WeakMap is to store ________ data for objects.

  • metadata
  • private
  • public
  • static
A common use case for WeakMap is to store metadata or additional information related to objects. Since WeakMap does not prevent object keys from being garbage collected, it's useful for storing data that should not interfere with garbage collection.

Is it possible to destructure properties from nested objects?

  • Yes
  • No
  • Only if the nested object has a single property
  • Only if the nested object is declared as a constant
Yes, in ES6, destructuring assignment can be used to extract properties from nested objects. This allows for a more convenient and concise way of accessing values within nested structures, enhancing code simplicity.

Asynchronous callbacks are placed in a queue known as the __________ queue.

  • Callback Queue
  • Event Queue
  • Promise Queue
  • Execution Queue
Asynchronous callbacks are placed in the Callback Queue, and they wait for the Event Loop to move them to the Call Stack for execution when the stack is empty.

Using _________, you can condense an array into a single value, optionally starting with an initial value.

  • map
  • reduce
  • filter
  • forEach
The correct answer is reduce. This method allows you to condense the elements of an array into a single value, using a provided function. It is particularly useful for tasks like summing values or finding the maximum element.