Node.js › Global Objects & the process Object
What is the global Buffer class, and how does it relate to the process object's broader role in giving access to system-level capabilities?
IntermediateAnswer
Buffer is a global class (no require() needed) for working with raw binary data directly, predating and complementing JavaScript's later-added standard TypedArray classes -- like process, it's part of Node.js's set of globals that expose lower-level, system-oriented capabilities not present in browser JavaScript, reflecting Node's original design goal of giving JavaScript direct access to I/O and binary data manipulation for building servers and system tools.
const buf = Buffer.from('Hello', 'utf-8');
console.log(buf); // <Buffer 48 65 6c 6c 6f>
console.log(buf.toString('utf-8')); // 'Hello'
console.log(buf.length); // 5
const buf2 = Buffer.alloc(10); // allocates 10 zeroed bytesReal-world example A binary file-parsing utility uses Buffer directly to read and manipulate raw bytes from a custom binary file format, relying on Buffer's specific methods for reading integers at specific byte offsets (readUInt32BE, etc.) that plain JavaScript strings or arrays don't provide.