I recently just started using
Uint8Array, Uint16Array, Uin32Array.
Uint*Arrays construct arrays (as commented by @zfor, they're not regular arrays, then there's no
push method, for example) with numbers (bytes, yet) only. The difference is that each constructor array has different byte range in memory.
Uint8Array has 1 byte only, then the limit of a number is
Uint16Array is 2 bytes long, then the limit is
Uint32Array is 4 bytes long, so the limit is
When constructing a Uint*Array you declare the array length as the first argument:
var arr = new Uint8Array(1);
If you declare a array/buffer/object instead, the constructor transform it in a
var arr = new Uint8Array([10, 257]); console.log(arr); // 10 console.log(arr); // 1 (same thing: 257 % 256)
Now, see some examples:
arr = 256; console.log(arr); // 0 arr = 255; console.log(arr); // 255