// Create a Buffer from a string
const buffer = Buffer.from('Hello, Node.js!');
// Print the Buffer as a string
console.log('Buffer:', buffer.toString());
code
Create and Print Buffer
This Node.js code creates a Buffer from the string 'Hello, Node.js!' and prints the content of the Buffer as a string. The comments provide explanations for each part of the code.
Node.js
Buffer
Buffer.from
Buffer toString