Typed Arrays: Numbers in Raw Bytes Playground
An ArrayBuffer’s four bytes are loose wagons on track 2: Wulan writes through one view and Mr. Wiryo reads through another. What becomes of 300 in a…
Try it in this playground
- Past 255 Write 300 into a Uint8Array to the end: 44 is stored, its lowest eight bits.
- Clamped, not wrapped Write 300 or -1 into a Uint8ClampedArray: it stops at 255 or 0.
- The same byte, another number Write 255 through a, then read it through b as an Int8Array: -1.
- Two byte orders Write 258 through an Int16Array, then read it with getInt16(0) and getInt16(0, true).