# math.clamp

Function · category: Math

Source: https://github.com/playcanvas/engine/blob/970d89f6d3bc6667f4e1f88153abd6e7e82ed52c/src/core/math/math.js#L34

```ts
clamp(value: number, min: number, max: number): number
```

Clamp a number between min and max inclusive.

**Parameters**

- `value` (`number`): Number to clamp.
- `min` (`number`): Min value.
- `max` (`number`): Max value.

**Returns** `number`: The clamped value.

**Example**

```ts
math.clamp(5, 0, 10);  // returns 5
math.clamp(-5, 0, 10); // returns 0
math.clamp(15, 0, 10); // returns 10
```
