/** * To convert between typed arrays an ArrayBuffer can be used to create * TypedArray's from one type to another. Each typed array has a property * which is an ArrayBuffer. **/ var uint16 = new Uint16Array([0x0102, 0x0304]); var uint32 = new Uint32Array(uint16.buffer); var uint8clamped = new Uint8ClampedArray(uint16.buffer); var uint8 = new Uint8Array(uint16.buffer); console.log('uint8', uint8); // uint8 [2, 1, 4, 3] console.log('uint8clamped', uint8clamped); // [2, 1, 4, 3] console.log('uint16', uint16); // [258, 772] console.log('uint32', uint32); // [50594050]