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 and Step both follow your edits
Loading...
Console
Output will appear here
Visualization
Result
Press Step to watch each line's result appear here
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.