ArtOfCode.org
Toggle Menu
Home
Online Rust Compiler
Tutorials
Algorithms 101
Html Css Tutorial
Javascript Tutorial
Blog
All Posts
Debugging and Error Handling in JS
Trace issues exceptions and logs.
1. Which error is thrown when a variable is used before it is declared?
ReferenceError
TypeError
SyntaxError
RangeError
2. Which of the following are built-in error types in JavaScript?
ReferenceError
HttpError
TypeError
SyntaxError
LogicError
3. The 'debugger' statement in JavaScript pauses execution and allows inspection in the browser's developer tools.
True
False
4. What keyword is used to manually throw an error in JavaScript?
5. In a try/catch statement, which block executes when no error occurs in the try block?
catch
finally
both catch and finally
none
6. Which console methods can be used for debugging purposes?
console.log
console.error
console.warn
console.debug
console.throw
7. A SyntaxError occurs when there is a mistake in the program's logic but the syntax is correct.
True
False
8. What property of an Error object contains a description of the error?
9. Which error type is thrown when a value is not of the expected type?
ReferenceError
TypeError
RangeError
SyntaxError
10. How can errors in Promise-based code be handled?
Using .catch() method
Wrapping in try/catch with async/await
Using throw inside the Promise
Using window.onerror
Using console.error()
11. The 'catch' block in a try/catch statement can omit the error parameter.
True
False
12. What is the name of the statement that enables stricter parsing and error checking in JavaScript?
13. Which method is used to handle uncaught exceptions globally in browsers?
window.onerror
process.on('uncaughtException')
try/catch
console.error
14. Which of the following are true about custom errors in JavaScript?
Created using throw new Error('message')
Can extend the Error class
Must include a 'name' property
Are automatically caught by try/catch
Cannot have custom properties
15. The stack property of an Error object provides the call stack leading to the error.
True
False
16. What keyword is used to declare a block that must execute after try/catch, whether an error occurred or not?
17. Which error occurs when a number is outside the allowable range?
RangeError
TypeError
ReferenceError
URIError
18. What are common debugging techniques in JavaScript?
Using console.log
Setting breakpoints in dev tools
Using the debugger statement
Code reviews
Ignoring errors
19. Async functions require wrapping await calls in try/catch to handle Promise rejections.
True
False
20. What is the name of the error thrown when decoding a URI fails?
Reset
Answered 0 of 0 — 0 correct