Error Handling

Try & Catch

Use try/catch to handle runtime errors gracefully and prevent script crashes.

Throwing Errors

Use throw to create custom errors when invalid conditions are detected.

Finally Block

The finally block always runs, making it ideal for cleanup operations.