- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Errors
JavaScript Errors
JavaScript Errors
An error stops the current code and travels up until something handles it.
An unhandled error stops the rest of the script from running.
That is why handling them matters so much on a real page.
Example
Example
javascript
let message;
try {
const value = null;
value.length;
} catch (error) {
message = "something went wrong";
}
console.log(message);The error was caught, so the program carried on.
