Chapter 10: Error Handling & Debugging

Execution context & Hoisting

Each time a script enters a new execution context, there are two phases of activity:

1. Prepare

2. Execute

Hoisting allows you to:

JavaScript Errors

  1. Error- generic error
  2. SyntaxError- syntax has not been followed
  3. ReferenceError- tried to reference a variable that is not declared/within scope
  4. TypeError- an unexpected data type that cannot be coerced
  5. RangeError- numbers not in an acceptable range
  6. URIError- encodeURI(), decodeURI(), snd similar methods used incorrectly
  7. EvalError- eval() function used incorrectly

Debugging Workflow

  1. Look at the error message
  2. Check how far the script is running
  3. Use breajpoints where things are going wrong

Debugging Tips

Common Errors