Standard built-ins
Uint8ClampedArray
Clamps numeric elements to 0–255 and rounds fractional values with ties to even.
Formal Syntax & Structure
javascript syntaxjavascript
new Uint8ClampedArray(iterable)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| iterable | Iterable<number> | Numeric elements to clamp; other overloads exist. |
Return Value
Uint8ClampedArray
Clamps numeric elements to 0–255 and rounds fractional values with ties to even.
Working Example
Example Snippetjavascript
(async () => {const a=new Uint8ClampedArray([-1,260,2.5,3.5]);console.log(JSON.stringify([...a]));})()