// Create a buffer from a string
const buffer = Buffer.from('Hello');
// Iterate using for...of loop
for (const byte of buffer) {
console.log(byte);
}
// Iterate using forEach
buffer.forEach((byte, index) => {
console.log(`Byte at position ${index}: ${byte}`);
});
72 101 108 108 111 Byte at position 0: 72 Byte at position 1: 101 Byte at position 2: 108 Byte at position 3: 108 Byte at position 4: 111