DEV Community

Talha Iqbal
Talha Iqbal

Posted on

Error Handling in JavaScript

Are tired of Errors?
Lets learn error handling in JavaScript in 60 seconds.

There are multiple types of error:
Syntax error, reference error Type Error, Range Error

we can deal with this by wrapping the block of code in try block
and catch the potential errors in catch block. This will prevents you program from crashing.

Image description

Image description

Beside the generic catch block you can catch specific type of error and preform action according to it.

Image description

There is one more thing the finally block.
it’s useful as it gets exceuted regardless of weather an error occurs or not.
It’s commonly use to perform cleanup operation.

This Is TI, SAYONARA

Top comments (0)