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.