Debugging & Errors Flashcards
1
Q
What are the steps of debugging?
A
- Reproduce the Error
- Determine the Boundaries of the Error
- Trace the Code
- Understand the Problem Well
- Implement a Fix
- Test the Fix
2
Q
What is a ReferenceError?
A
AReferenceError
occurs when you attempt to use a variable or function that doesn’t exist.
3
Q
What is a TypeError?
A
- accessing a property on a value that does not have any properties, such as
null
orundefined
- trying to call something that isn’t a function can also raise a
TypeError
- trying to reassign a
const
variable:
4
Q
What is a SyntaxError?
A
A SyntaxError occurs when the program does not use proper JS syntax.
5
Q
What is the syntax for a catch statement?
A
try {
// Do something that might fail here and throw an exception.
} catch (error) {
// This code only runs if something in the try clause throws an exception.
// “error” contains the exception object.
} finally {
// This code always runs even if the above code throws an exception.
}
6
Q
What conditions should be met before you use a catch statement?
A
- A built-in JavaScript function or method can throw an exception and you need to handle or prevent that exception.
- A simple guard clause is impossible or impractical to prevent the exception.