xxxxxxxxxx
const uint8Array = new Uint8Array(4);
const index = 5;
if (index >= 0 && index < uint8Array.length) {
// Perform the operation only if the index is within bounds
uint8Array[index] = 42;
} else {
console.error('Index is out of bounds.');
}