JavaScript Uint8ClampedArray
Description
Uint8ClampedArray array represents atyped array of 8-bit unsigned integers.
Uint8ClampedArray contents are initialized to 0 by default.
Uint8Array vs Uint8ClampedArray
The difference between an Uint8Array and an Uint8ClampedArray is how values are added.
If you set one element in an Uint8ClampedArray to a value outside the 0-255 range,it will default to 0 or 255.
A typed array will just take the first 8 bits of the value.
Constructor Syntax
new Uint8ClampedArray(length)
new Uint8ClampedArray(object)
new Uint8ClampedArray(object)
Parameters
| Parameter | Description |
| length | Optional. The length of the typed array (number of elements). |
| object | Optional. Object to create the typed array from. |
JavaScript Typed Arrays
Browser Support
Uint8ClampedArray is an ECMAScript6 (ES6 2015) feature.
JavaScript 2015 is supported in all browsers sinceJune 2017:
| Chrome 51 | Edge 15 | Firefox 54 | Safari 10 | Opera 38 |
| May 2016 | Apr 2017 | Jun 2017 | Sep 2016 | Jun 2016 |

