Handle failure at useful boundaries.
- throw
- Error
- try/catch/finally
- validation
Throw an Error when a function cannot fulfill its contract. Catch errors where you can recover or present a helpful message; otherwise let them surface for debugging. Use finally for cleanup that must run whether work succeeds or fails.
Silently swallowing every error hides bugs and leaves users with unclear states.
Write a parser that rejects invalid input with a clear error and show a friendly message to the user.
Open example.html in a browser and edit example.js. Save, refresh, and use the Console and debugger to inspect values.
- Explain the core idea in your own words without reading the code.
- Change one input and predict the output before running it.
- Test one boundary or failure case, then record what you changed.