---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---
# Uint8ClampedArray

The **`Uint8ClampedArray()`** constructor creates a typed array
of 8-bit unsigned integers clamped to 0-255; if you specified a value that is out of the
range of \[0,255], 0 or 255 will be set instead; if you specify a non-integer, the
nearest integer will be set. The contents are initialized to `0`. Once
established, you can reference elements in the array using the object's methods, or
using standard array index syntax (that is, using bracket notation).

## Syntax

```js
new Uint8ClampedArray()
new Uint8ClampedArray(length)
new Uint8ClampedArray(typedArray)
new Uint8ClampedArray(object)

new Uint8ClampedArray(buffer)
new Uint8ClampedArray(buffer, byteOffset)
new Uint8ClampedArray(buffer, byteOffset, length)
```

> **Note:** `Uint8ClampedArray()` can only be constructed with `new`. Attempting to call it without `new` throws a [`TypeError`](../../globals/TypeError/TypeError.mdx).

### Parameters

See [`TypedArray`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#parameters).

### Exceptions

See [`TypedArray`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/TypedArray#exceptions).
