Difference between Uint8Array and Uint8ClampedArray
问题 What is the difference between Uint8Array and Uint8ClampedArray in JavaScript? I understand that Uint8ClampedArray is used with canvas for pixel manipulations. Why is that and what is the benefit? 回答1: Looking at the examples for Uint8ClampedArray and Uint8Array, it looks like the difference is how values are treated when assigned. If you are trying to set one element to a clamped array to any value outside of the range 0-255 , it will simply default to 0 or 255 (depending on whether the