Debugging & Errors Flashcards

1
Q

What are the steps of debugging?

A
  1. Reproduce the Error
  2. Determine the Boundaries of the Error
  3. Trace the Code
  4. Understand the Problem Well
  5. Implement a Fix
  6. Test the Fix
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a ReferenceError?

A

AReferenceErroroccurs when you attempt to use a variable or function that doesn’t exist.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a TypeError?

A
  1. accessing a property on a value that does not have any properties, such asnullorundefined
  2. trying to call something that isn’t a function can also raise aTypeError
  3. trying to reassign aconstvariable:
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is a SyntaxError?

A

A SyntaxError occurs when the program does not use proper JS syntax.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly