I understand why I need to use Buffer.
But I'm not super clear about the actual use of buffer syntax.
in the example below,
const parsedBody = Buffer.concat(body).toString();
const message = parsedBody.split('=')[1];
fs.writeFileSync('receivedText', message);
buffer was used to make a delay before
const message = parsedBody.split('=')[1];
fs.writeFileSync('receivedText', message);
is excuted.
but syntax-wise it's bit strage for me.
What if I want to make an array of many things, like
let arr=[]
for (let i=0; i<10; i++){
arr.push('hi')
}
I'm pretty sure that I can't do simply like
Buffer.(
let arr=[]
for (let i=0; i<10; i++){
arr.push('hi')
}
)
It feels like an async function and await combination though, I believe there must be something behind the scene.
As a simple example answer for that, What should I do if I want to do for loop using Buffer?
Thank you in advance.
0x00etc. Buffer is needed to handle things that are not strings like JPEG images, MP4 videos etc and storing them in variables.