Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将 a Uint8ClampedArray(例如用于存储 HTML5 画布图像数据的)转换为常规数组,其中的值不会被限制为0- 255?
Uint8ClampedArray
0
255
您可以使用以下方法将类型化数组转换为常规数组Array.prototype.slice
Array.prototype.slice
var typedArray = new Uint8ClampedArray([1, 2, 3, 4]); var normalArray = Array.prototype.slice.call(typedArray);
此外,如果使用 ES6,您可以Array.from改用:
Array.from
var normalArray = Array.from(typedArray);
请参阅MDN - JavaScript 类型化数组