# try Block

A block containing code that may throw an exception.

## What is **try Block** in JavaScript?

**try Block** — A block containing code that may throw an exception.

```javascript
function reserve(seats) {
    if (seats < 1) {
        throw new Error("Seat count must be positive");
    }
}
```

Level: Journeyman · [More JavaScript terms at this level](https://www.ask-codey.com/glossary/subjects/javascript/journeyman)

Updated: September 27, 2026

## In other subjects

- [try Block in C#](https://www.ask-codey.com/glossary/try-block-c-sharp)
- [try Block in Java](https://www.ask-codey.com/glossary/try-block)

Source: https://www.ask-codey.com/glossary/try-block-javascript
