To process each element in an array and build a new array with elements that pass certain criteria, use _________.

  • map
  • forEach
  • reduce
  • filter
The filter method is used to create a new array with elements that pass a certain condition specified in a callback function.

How do you embed expressions within a template literal?

  • Place the expression inside ${}
  • Use single quotes around the expression
  • Enclose the expression in square brackets
  • Use the at symbol (@)
Expressions are embedded within a template literal using ${}. This syntax allows you to insert dynamic content directly into the string, providing a concise and readable way to include variables or expressions in your strings.

In a logging function, how can default parameters be used to control the verbosity of the logs?

  • Set a default verbosity level, and users can adjust it by providing an optional parameter, like log(message, verbosity = 1).
  • Use default parameters to enable users to specify different levels of verbosity, such as log(message, level = "info").
  • Allow users to pass a verbosity parameter and use default parameters to handle cases where no verbosity level is provided.
  • Implement default parameters for both message and verbosity, allowing users to adjust verbosity while still logging a default message.
Default parameters can be employed in a logging function to control the verbosity of the logs. By setting a default verbosity level, users can choose to override it when calling the function, providing flexibility in controlling the amount of detail in the logs. It simplifies the logging function's usage while still offering customization based on the user's needs.

Q2: If you are managing a group of user objects, each with associated metadata, how would using a WeakMap affect memory management compared to using a Map?

  • WeakMap
  • Map
  • Both WeakMap and Map
  • Neither WeakMap nor Map
Using a WeakMap for managing user objects with associated metadata is advantageous for memory management. In a WeakMap, keys are weakly referenced, meaning that if there are no other references to a key, it can be garbage collected. This is useful when managing user objects because if a user object is removed elsewhere in the application, the associated metadata can also be automatically cleared from the WeakMap, preventing unnecessary memory consumption. A Map, on the other hand, would retain the user objects in memory even if they are no longer needed, potentially leading to memory issues.

Can template literals be used for multi-line string formatting?

  • Yes
  • No
  • Only with the use of the escape character
  • Depends on the browser support
Template literals in JavaScript can be used for multi-line string formatting by directly including line breaks within the backticks. This makes it easier to create and maintain multiline strings without the need for explicit concatenation or escape characters.

What is the significance of the done property in the object returned by the next() method of a generator?

  • It indicates if the generator is done executing
  • It represents the final result of the generator
  • It is always set to false
  • It is used for error handling
The done property in the object returned by the next() method of a generator indicates whether the generator has completed its execution. When done is true, it means the generator has finished, and no more values will be generated. This is crucial for controlling the flow of iteration and termination of the generator.

In a scenario where you are extending a base class, how would overriding and extending methods impact the functionality of your derived class?

  • Overriding can modify the behavior of a method in the derived class, while extending adds new functionality.
  • Overriding and extending have the same impact on the derived class.
  • Overriding and extending methods are not possible in ES6.
  • Overriding and extending methods will lead to a compilation error.
When extending a base class in ES6, you can override existing methods in the derived class to modify their behavior. Overriding allows you to customize the functionality of inherited methods. Additionally, you can extend the base class by adding new methods in the derived class, providing additional functionality without modifying the base class. This flexibility enhances code reuse and adaptability.

What type of operations can be improved through performance tuning in DB2?

  • Data deletion
  • Data encryption
  • Data insertion
  • Data retrieval
Performance tuning in DB2 can improve various operations such as data retrieval by optimizing SQL queries, creating appropriate indexes, and configuring memory settings to enhance overall system performance. 

Third-party command line tools may offer specialized features for ________ tasks in DB2 administration.

  • Backup and Recovery
  • Monitoring
  • Performance Tuning
  • Security
Third-party command line tools may offer specialized features for performance tuning tasks in DB2 administration. These tools often provide advanced performance analysis, optimization, and tuning capabilities to enhance the overall performance and efficiency of DB2 databases and applications. 

How does DB2 implement optimistic concurrency control?

  • Locking Mechanisms
  • MVCC (Multi-Version Concurrency Control)
  • Timestamp-based Concurrency Control
  • Two-Phase Locking
DB2 implements optimistic concurrency control through MVCC (Multi-Version Concurrency Control). This mechanism allows transactions to proceed without waiting for others to complete, by maintaining multiple versions of a data item. When a transaction reads a data item, it gets a timestamp, and if another transaction updates the same data after that timestamp, the database creates a new version of the data, maintaining the older version for read consistency. MVCC reduces contention and improves concurrency in DB2 systems.