What *actually* is a Buffer?

What are Buffers?

A buffer is a container for raw bytes. A byte just means eight bits (0 or 1), so a byte might look like 00110101, but this you probably already know.

A Buffer visualization through console.log() method in Node.JS
This is what a Buffer look like when printed in Node.JS
A table of binary to hexadecimal convertions
A quick guide on what binary numbers correspond to Hexadecimal numbers

Buffers in Node.JS

There are lot of ways to create a buffer but the simplest is probably just using the alloc method. If you know you’re going to fill up the buffer immediately then you can use allocUnsafe which is more efficient but doesn’t clear out random unused bytes from the buffer.

Things you may ask

at least, I thought about it.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
João Augusto Perin

João Augusto Perin

6 Followers

I don’t know how to describe myself actually…maybe a hypothetical jedi? God no…that sounds like a bad album title from an underground 80’s band.