Buffers
A Buffer is a fixed size chunk of raw bytes. Use it for binary data and encodings such as utf8, hex and base64.
Example
const b = Buffer.from('Hello', 'utf8');
console.log(b.length, b[0]);
console.log(b.toString('hex'));
console.log(b.toString('base64'));
console.log(Buffer.from('SGVsbG8=', 'base64').toString());Result
5 72 48656c6c6f SGVsbG8= Hello
Exercise
Create a buffer from text.
Buffer.("hi")
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.