You can convert a typed array to a regular array by using Array.prototype.slice
var typedArray = new Uint8ClampedArray([1, 2, 3, 4]);
var normalArray = Array.prototype.slice.call(typedArray);
Also if using ES6 you may be able to use Array.from instead:
var normalArray = Array.from(typedArray);
See MDN - JavaScript typed arrays
Answer from Austin Greco on Stack OverflowI think you shouldn't be using Uint8Array to store your data - it simply doesn't work like a Uint8ClampedArray. For example:
a = new Uint8Array(1);
b = new Uint8ClampedArray(1);
a[0] = 256;
b[0] = 256;
a[0] === 0; // true
b[0] === 255; // true
I would just use a regular array (if that's an option) and clamp the values when you store them into it, or when you read them to generate your string like this:
s += String.fromCharCode(Math.max(0, Math.min(255, array[i])));
The WhatWG has recommended the Uint8ClampedArray for storing canvas pixel data.
But, various browsers use Uint8ClampedArray (or not) depending on whether they've implemented the WhatWG recommendations.
Therefore, a more cross-browser solution is to pull an array from your canvas using .getImageData and then manipulate that array as desired. That way you know you're using a compatible array.
var imageData = context.getImageData(0,0,canvas.width,canvas.height);
var data = imageData.data; // this array is always compatible with its browser.