What method is used to resume the execution of a generator function?

  • resume()
  • continue()
  • next()
  • run()
The correct method to resume the execution of a generator function is next(). This method is called on the Generator object and proceeds to the next yield statement, returning the yielded value. Options a), b), and d) are incorrect and not used for resuming a generator function.

Tagged template literals allow you to parse template literals with a _________ function.

  • Regular
  • Parse
  • Tag
  • Transform
In ES6, tagged template literals use a tag function to parse the template literal. This function, often referred to as the tag, allows you to process the template and its interpolated values before producing the final string.

How does the 'use strict' mode affect class behavior in ES6?

  • It enforces stricter type checking in class properties
  • It allows for dynamic addition of properties in a class
  • It has no impact on class behavior
  • It throws an error if the class contains undeclared variables
In 'use strict' mode, the class behavior becomes more rigid. It disallows the usage of undeclared variables, ensures that the 'this' keyword behaves more predictably, and generally promotes safer coding practices.

If a property is not found on an object, JavaScript looks up the property on the object's prototype, known as the _________ chain.

  • Prototype
  • Scope
  • Inheritance
  • Execution
In JavaScript, the process of searching for a property involves traversing the prototype chain. If the property is not found on the object, it looks up in the prototype chain until it finds the property.

In ES6, what is the difference between declaring methods in a class and in an object literal?

  • Methods in a class are enumerable, while methods in an object literal are not
  • Methods in a class are prototype methods, while methods in an object literal are not
  • There is no difference between declaring methods in a class and in an object literal
  • Methods in an object literal have access to the 'super' keyword
The key distinction is that methods in a class are prototype methods, meaning they are shared among all instances of the class. In contrast, methods in an object literal are not shared among instances.

How does error propagation work in a Promise chain?

  • Propagates to the nearest catch block
  • Propagates to the outermost catch block
  • Propagates to the nearest then block
  • Propagates to the global error handler
In a Promise chain, errors propagate to the nearest catch block. If there isn't a catch block in the immediate chain, it continues to propagate outward until it finds one. This behavior allows for more granular error handling based on where the error occurs in the chain.

What keyword is used to define a generator function in JavaScript?

  • function*
  • gen
  • generator
  • yield
The correct keyword to define a generator function in JavaScript is function*. It uses the asterisk (*) after the function keyword. This syntax indicates that the function is a generator. Options b) and c) are incorrect, and d) is used within the generator function to yield values.

In a WeakMap, keys must be ________ and not primitive values.

  • Objects
  • Strings
  • Numbers
  • Booleans
In a WeakMap, keys must be objects, as primitive values are not allowed as keys. This is because WeakMap uses "weak" references to the keys, and primitive values do not have references like objects.

An unhandled promise rejection can be caught globally using process.on('________', handler).

  • rejection
  • unhandledRejection
  • promiseError
  • errorHandled
In Node.js, the 'unhandledRejection' event is emitted when a Promise is rejected but no handler is provided. Using process.on('unhandledRejection', handler) allows you to catch and handle such rejections globally.

What is the primary purpose of tree shaking in JavaScript modules?

  • Eliminating Unused Code
  • Minifying the Code
  • Enhancing Code Readability
  • Improving Network Performance
Tree shaking is a process in JavaScript where unused or dead code is eliminated from the final bundle during the build process. The primary purpose is to reduce the size of the bundle by removing parts of the code that are not actually used, thus improving the application's performance and loading times. It helps in optimizing the overall efficiency of the application by excluding unnecessary code.