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.

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.

When using default export, you can rename the imported module without using the _________ syntax.

  • import customName from
  • import as customName from
  • import {customName} from
  • import default as customName
In ES6, when importing a module with a default export and renaming it, you use the import customName from 'moduleName'; syntax. The as keyword is not required in this context.

In ES6, can the rest operator be used in conjunction with destructuring to extract specific elements from an array?

  • Yes, the rest operator allows extracting specific elements by using the spread syntax.
  • No, the rest operator can only be used to extract all elements in an array.
  • Yes, the rest operator can be combined with destructuring to extract specific elements.
  • No, the rest operator is not compatible with array destructuring.
In ES6, the rest operator can indeed be used in conjunction with array destructuring to extract specific elements. It allows you to capture the remaining elements of an array into a new array variable.

ES6 allows the use of ________ to dynamically create property names in object literals.

  • Template Literals
  • Default Parameters
  • Rest Parameters
  • Spread Operator
Template literals in ES6 provide a powerful way to create strings, allowing dynamic expression evaluation. This feature is often used to create dynamic property names in object literals.

For side effects only, import a module without any exported bindings using import '________';.

  • module-name'
  • {} from 'module-name'
  • from 'module-name'
  • module-name';
When importing a module for its side effects only, you can use import 'module-name'; without any specific binding. This is useful when a module has side effects like modifying the global scope.

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.

What is a key difference between functional composition and method chaining?

  • Method chaining involves calling methods directly on an object, while functional composition combines functions to create new functions
  • Functional composition is only applicable in functional programming languages
  • Method chaining can only be used with asynchronous functions
  • All functions used in functional composition must be pure functions
Functional composition involves combining functions to create more complex ones, whereas method chaining is about calling methods directly on an object. Understanding this difference is crucial for designing clean and readable 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.

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.

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.

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.