Node.js Tutorial – Buffer Class

Node.js – Class buffer

The node.js performs the streams and file system operations for interacting with operating system or other run time processed and uses buffer objects to represent the binary data in the form of a sequence of bytes.

The node.js buffers is the sub-class of  Uint8Array  which in built on the JavaScript language and provides numerous methods. The node.js APIs accepts  plain Uint8Array whenever the buffer instances are created and are similar to arrays of integers from 0 to 255

The node.js buffer size allocation is provided at the creation of the instance and has fixed-size blocks of memory which cannot be changed.

node.js buffer examples

// creates zero-filled Buffer of length 10.
const zeroFilledBuffer = Buffer.alloc(10);

// Creates a Buffer containing the bytes [4,5,6].
const containsBytes = Buffer.from([4, 5,6]);

Node.js Tutorial – Buffer Class
Scroll to top
Copy Protected by Chetan's WP-Copyprotect.