try-catch in JavaScript
The try-catch statement in JavaScript allows you to handle errors gracefully. It consists of two main blocks:
tryblock: Contains code that may throw an error.catchblock: Executes if an error is thrown in thetryblock. It catches the error and handles it to prevent the script from crashing.
Syntax:

- error occurred when not handled using try-catch

- error handling using try-catch

- you can also print the error using catch(e) or catch(error)