// allocate a buffer of size 10 bytes and fill with zeros const buf = Buffer.alloc(10); // print the contents of the buffer console.log(buf); // Output:
// create a buffer from a string const buf = Buffer.from("hello world"); // print the contents of the buffer console.log(buf); // Output:In both examples, the Buffer class is used without requiring any external package libraries.