JSVerse
Fundamentals / Error Handling

Error Handling

try, catch, finally — and the three most common runtime errors.

Code inside `try` runs normally until something throws. If it does, execution jumps straight into `catch`, skipping the rest of `try`. `finally` runs no matter what — whether an error was thrown or not. The most common built-in error types are ReferenceError (using an undeclared name), TypeError (using a value the wrong way, like calling a non-function), and SyntaxError (malformed code, caught before anything runs).

Codeeditable — Run executes your edits
Loading...
Console
Output will appear here
Visualization
State
Step through — the console panel shows what's happening
Why?

Reading .value off of null makes no sense to the engine, so it throws a TypeError immediately — execution never reaches the console.log inside try.