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.
Loading...
Related Quiz
- What considerations should be made while implementing asynchronous middleware in Express.js?
- You are developing an Express application that requires user authentication. How do you ensure that user credentials are secured, and sessions are managed effectively across different routes?
- Express.js middleware functions have access to the ______ object, the ______ object, and a next function in their callback function parameters.
- How can you handle error events emitted by the request object in the http module?
- What is the result of using the spread operator on a string, such as ...“JavaScript”?