# if Statement

*noun*

say it: **“IF STAYT-ment”** **/ɪf ˈsteɪtmənt/**

Code that runs a block only when its condition is true, as in if (total > 25) { ... }.

## What does **if Statement** do in JavaScript?

**if Statement** — Runs a block of code only when a condition is true.

```javascript
if (stock > 0) {
    status = "Available";
} else {
    status = "Sold out";
}
```

## In a sentence

- “My **if statement** prints "Free delivery!" only when the order is over $25.”

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

Updated: November 9, 2026

## In other subjects

- [if Statement in C#](https://www.ask-codey.com/glossary/if-statement-c-sharp)
- [If Statement in C#](https://www.ask-codey.com/glossary/if-statement-c-style)
- [if Statement in Java](https://www.ask-codey.com/glossary/if-statement-java)
- [if Statement in PowerShell](https://www.ask-codey.com/glossary/if-statement-powershell)
- [if Statement in Python](https://www.ask-codey.com/glossary/if-statement)
- [if Statement in Unix](https://www.ask-codey.com/glossary/if-statement-unix)

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