Understanding the try Block
Which block is used in JavaScript to wrap code that may cause an error?
- monitor
- catcher
- trap
- caught
- try
Correct Catch Block Syntax
What is the correct way to start a catch block after a try block in JavaScript?
- catching(error)
- catch: error
- catch(error)
- catcher(error)
- catch error
Purpose of finally Block
Which JavaScript block is always executed after try and catch, regardless of whether an error occurred?
- complete
- finish
- done
- end
- finally
Using throw Statement
Which statement is used in JavaScript to manually trigger an error?
- raise
- rise
- throw
- emit
- error
Error Object Basics
What does the built-in Error object in JavaScript represent?
- A log entry
- An exception that is thrown
- A successful result
- A function callback
- A warning message
Accessing Error Message
After an error is caught, which property of the error object contains the error message?
- msg
- reason
- message
- detail
- description
Handling Errors Gracefully
What is one main advantage of using try/catch in JavaScript?
- It disables error logging
- It automatically fixes syntax errors
- It allows handling errors without stopping script execution
- It slows down the program intentionally
- It checks for memory leaks
Custom Error Throwing Example
What happens when the following code is executed? throw new Error('Invalid input');
- A warning is displayed but code continues
- An error is created and thrown with the message 'Invalid input'
- The code is ignored and nothing happens
- The error is silently logged
- JavaScript restarts the program
Catching Specific Error Types
In JavaScript, which error object is specifically thrown for references to undefined variables?
- ValueError
- TypeError
- ErrorRef
- ReferenceError
- SyntaxError
Understanding Error Propagation
If an error is not caught inside a try/catch block, what typically happens in JavaScript?
- The script pauses and resumes
- The error is fixed automatically
- A custom handler always runs
- The error propagates up and may stop script execution
- The code jumps to the start
Order of Execution
Given a try/catch/finally structure, which block is always executed regardless of errors?
- lastly
- finally
- finish
- always
- done
Creating Custom Errors
How do you create a custom error type in JavaScript?
- By extending the Error class
- By defining an error in catch
- By setting error.custom = true
- By calling createError()
- By using 'makeError'
Handling Syntax Errors
Can a try/catch statement catch syntax errors that occur during JavaScript parsing?
- No, syntax errors occur before try/catch runs
- Yes, but only with custom errors
- Only with the 'catchAll' method
- Only if using finally
- Yes, always
Accessing Error Name
Which property of the error object in JavaScript gives the type of error?
- name
- class
- category
- error
- type
Error Handling in Asynchronous Code
When using Promises, which method is typically used to handle errors instead of try/catch?
- catcher()
- trap()
- error()
- catch()
- throw()