Error Handling and Debugging (original) (raw)
What is the purpose of the try...catch block in JavaScript?
- To handle asynchronous code
- To handle errors during code execution
- To stop the execution of a program
- To skip specific lines of code
Which statement is used to manually throw an error in JavaScript?
What is the Error object used for?
- To create custom error messages
- To debug code by printing logs
- To represent runtime errors in JavaScript
What is the output of the following code?
JavaScript `
try { console.log(a); } catch (e) { console.log(e.message); }
`
- ReferenceError: a is not defined
Which console method is used to display a table of data?
What happens if there is no catch block for a thrown error?
- The program continues execution
- The program crashes or stops execution
- A warning is displayed in the console
Which of the following methods halts the browser's execution to inspect the code?
What is the purpose of the finally block in error handling?
- Executes only if an error occurs
- Executes only if no error occurs
- Executes after the try and catch blocks, regardless of errors
- Stops the error from propagating further
Which of the following is NOT a console method?
What is the primary advantage of using a linter like ESLint in debugging?
- Automatically fixes all errors in code
- Highlights potential errors and enforces coding standards
- Pauses execution of the code
- Provides runtime debugging tools
There are 10 questions to complete.
Take a part in the ongoing discussion