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.

Higher-order functions improve code __________ by allowing for more abstract and concise code.

  • Efficiency
  • Readability
  • Performance
  • Execution
By using higher-order functions, code becomes more readable and expressive. It abstracts away the details of how a particular operation is performed, making the code concise and easier to understand.

How does inheritance of static methods differ from that of instance methods in ES6?

  • Static methods cannot be inherited.
  • Static methods are inherited through the prototype chain.
  • Static methods are inherited using the extends keyword.
  • Static methods are inherited through the super keyword.
In ES6, static methods are inherited through the prototype chain, just like instance methods. The key difference lies in how they are called and accessed. The extends keyword is used to inherit static methods, making them accessible through the derived class. Option B is the correct answer.

What is the primary purpose of the async keyword in a function declaration?

  • Enables the function to return a Promise
  • Specifies that the function can be called asynchronously
  • Defines a function that can only be executed in an asynchronous manner
  • Marks a function as an asynchronous event handler
The async keyword is used to make a function return a Promise. This allows the use of await within the function, indicating that it contains asynchronous code.

Given a scenario where you need to process each character of a string individually, how would you utilize an iterator?

  • Iterate through the string using a for loop
  • Use the Array.from() method to convert the string to an array and then iterate
  • Utilize the string's forEach method
  • Use the for...of loop to iterate over the string
In this scenario, using the for...of loop is the most concise and readable way to iterate over each character of a string. The for...of loop works specifically for iterable objects, and strings are iterable in JavaScript. It simplifies the code and enhances readability.