How can you allocate a buffer of a specified size without initializing it in Node.js?
- Buffer.alloc(size)
- Buffer.create(size)
- Buffer.new(size)
- Buffer.allocate(size)
To allocate a buffer of a specified size without initializing it in Node.js, you should use the Buffer.alloc(size) method. It allocates a new buffer of the given size and initializes it with zeros. The other options are not valid methods for achieving this.
Loading...
Related Quiz
- When creating a mock object, what is typically expected regarding the behavior of the methods?
- In Node.js, '______' is used to signify the end of a writable stream.
- In a token-based authentication system, using a ______ approach helps in reducing the risk of token interception and replay attacks.
- In Node.js, what is the purpose of the process.on('uncaughtException', handler) method?
- You are maintaining a server that has strict security requirements. You need to allow cross-origin requests but with stringent restrictions. How can you implement CORS to fulfill these requirements while maintaining security?