How can you create a buffer instance in Node.js?

  • new Buffer(10)
  • Buffer.alloc(10)
  • createBuffer(10)
  • buffer.create(10)
In Node.js, you can create a buffer instance using the Buffer.alloc(size) method, where size is the desired size of the buffer in bytes. The new Buffer() constructor is deprecated, and the other options are not valid ways to create a buffer in Node.js.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *