Stage 1 · Lesson 8 of 10
Errors, try/catch and debugging
When something goes wrong, JavaScript an error object. It has a name, a message and a , the list of calls that led there. Read the first line in the terminal or the browser console.
TypeError: Cannot read properties of undefined usually means a value you expected was missing one step earlier. Error handling for expected failures uses try, catch and finally. A good example is with JSON.parse when the text may not be valid.
Throw your own errors with throw new Error("amount must be positive"). Do not wrap everything in try and silently ignore the error, because that hides bugs. When the output is wrong but there is no error, use a debugger.
Set a breakpoint in VS Code or the browser , then step through line by line, watching the variables.
A question to check yourself, an AI practice session and 2 cheat sheet entries come when you add the roadmap to your account. Add it
Resources for this stage
Start with· follow one of these
- CoursePaidGrokking JavaScript Fundamentals
Design Gurus · Beginner · $50
The language itself, closures and async included, with runnable exercises per lesson
- GuideFreeJavaScript.info
Ilya Kantor
Free: Part 1 is the most complete modern JavaScript tutorial, with tasks per chapter