Node.js Buffers: Handling Raw Binary Data
A Node.js Buffer is a fixed-size chunk of memory for raw binary data, like an array of bytes. Use it for file I/O or network streams where JS strings fail. The footgun is using `allocUnsafe()` without overwriting it, which can leak old, sensitive data.
Think of a Node.js Buffer as a fixed-size chunk of memory for raw binary data—an array of bytes. While JavaScript strings handle text, Buffers let you interact with binary streams from files or networks. This is essential for file I/O, TCP sockets, or cryptography. The biggest footgun is using `Buffer.allocUnsafe()` for speed without immediately overwriting its contents, which can leak sensitive data from previous memory allocations.
Read the original → nodejs.org
- #node.js
- #binary
- #memory
- #streams
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.