JavaScript Error Handling

Explore exceptions,try-catch blocks,and debugging best practices.

1. What is the correct syntax to handle errors in JavaScript?
2. Which block is used to enclose code that might throw an error?
3. Which error type occurs when accessing an undefined variable?
4. Which block handles errors thrown in the try block?
5. What happens if an error is thrown in a try block with no catch block?
6. Which property of an error object contains the error message?
7. What is the output of: try { throw 'oops'; } catch(e) { console.log(e); } finally { console.log('done'); }
8. Which error is thrown when a value is not of the expected type (e.g., calling a string as a function)?
9. Which of the following are valid error-handling constructs in JavaScript?
10. What can be thrown using the 'throw' statement?
11. Which are built-in error types in JavaScript?
12. Which properties do standard Error objects have?
13. How can you handle errors with async/await?
14. The finally block is optional in a try/catch structure.
15. try...catch can only handle errors in synchronous code.
16. Throwing an error stops execution of the current function.
17. The Error constructor requires a message parameter.
18. What keyword defines a block that executes after try/catch, regardless of errors?
19. What property of an Error object returns a string representing the call stack trace?
20. Name the error type thrown when a number is outside the allowable range (e.g., new Array(-1)).
Answered 0 of 0 — 0 correct