# throw

*noun*

say it: **“THROH”** **/θroʊ/**

A statement that stops the current function on purpose and hands an error to the nearest catch, as in throw new Error("Servings must be more than 0").

## What does **throw** do in JavaScript?

**throw** — A statement that deliberately raises an exception object.

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

## In a sentence

- “If servings is 0, the function will **throw** an error instead of returning a wrong recipe.”

Level: Journeyman · [More JavaScript terms at this level](https://www.ask-codey.com/glossary?category=javascript&level=3)

Updated: November 9, 2026

## In other subjects

- [throw in C#](https://www.ask-codey.com/glossary/throw-c-sharp)
- [throw in Java](https://www.ask-codey.com/glossary/throw)
- [throw in PowerShell](https://www.ask-codey.com/glossary/throw-powershell)

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