Complete the code to convert a Buffer to a string using the default encoding.
const buf = Buffer.from('hello'); const str = buf.[1]();
The toString() method converts a Buffer to a string using UTF-8 encoding by default.
Complete the code to convert a Buffer to a string using 'utf8' encoding explicitly.
const buf = Buffer.from('world'); const str = buf.toString('[1]');
Specifying 'utf8' ensures the buffer is decoded as UTF-8 text.
Fix the error in the code to correctly convert the Buffer to a string.
const buf = Buffer.from('test'); const str = buf.[1]('utf8');
The correct method to convert a Buffer to a string is toString(). Other methods do not exist or do not perform this conversion.
Fill both blanks to convert a Buffer to a string using 'base64' encoding and assign it to a variable.
const buf = Buffer.from('data'); const encoded = buf.[1]([2]);
Use toString('base64') to convert the Buffer to a base64 encoded string.
Fill all three blanks to convert a Buffer to a string with 'hex' encoding and store it in a variable named hexString.
const buf = Buffer.from('example'); const [1] = buf.[2]([3]);
Assign the result of buf.toString('hex') to the variable hexString to get the hex representation.