As you can read in the Node.js documentation on the Buffer class, a buffer
is similar to an array of integers but corresponds to a raw memory allocation o
BUFFER
is a temporary holding spot for data being moved from one place to another.
In order to understand what is Buffer, we need to know how a computer will process things. See the chart below.
The concept is like if you are watching a Youtube Video, you can start to watch a video without downloading the whole video. If your internet speed is too slow, you would see "buffering", that means the computer is trying to collect data in order for you to keep watching that video.
Explanation from http://nodejitsu.com/...
Buffers are instances of the Buffer class in node, which is designed to handle raw binary data. Each buffer corresponds to some raw memory allocated outside V8. Buffers act somewhat like arrays of integers, but aren't resizable and have a whole bunch of methods specifically for binary data. In addition, the "integers" in a buffer each represent a byte and so are limited to values from 0 to 255 (2^8 - 1), inclusive.
Read more: Buffers in Node.js
A Buffer is a chunk of memory, just like you would have it in C/C++. You can interpret this memory as an array of integer or floating point numbers of various lengths, or as a binary string. Unlike higher-level data structures like arrays, a buffer is not resizable.
It corresponds roughly to:
char*
or char[]
in C/C++byte[]
in Javabytes
or a non-resizable bytearray
in Python