const bytes = new Uint8Array([1, 2, 3, 4, 5]);
// Properties
bytes.length; // 5
bytes.byteLength; // 5
bytes.byteOffset; // 0
bytes.buffer; // ArrayBuffer
// Slice
const slice = bytes.slice(1, 4); // [2, 3, 4]
// Subarray (view, not copy)
const sub = bytes.subarray(1, 4); // [2, 3, 4]
// Set
bytes.set([10, 20], 0); // [10, 20, 3, 4, 5]
// Copy within
bytes.copyWithin(0, 3); // [4, 5, 3, 4, 5]
// Fill
bytes.fill(0); // [0, 0, 0, 0, 0]
// Find
bytes.indexOf(3); // -1
bytes.includes(0); // true
// Iteration
for (const byte of bytes) {
console.log(byte);
}