Recent Posts

Caution: Greetings to all visitors. The site is working in short. Links Please skip the link to view any topic and thank you for visiting
header ads

+= vs push | which one is better to add data to an array

Hi guys,
Long story short, I read a file with a file reading API then sliced readable data into chunks and send them to reassemble by another function to avoid reading large amount of data.
Part of the code would look like this:

var data = '';
request.on('data', (chunk) => {
    data += chunk;
}).on('end', () => {
    // do something with the data
});
Code (markup):
Then I found that someone does it like this:

var data = [];
request.on('data', (chunk) => {
    data.push(chunk);...
Code (markup):
+= vs push | which one is better to add data to an array

from JavaScript https://ift.tt/37bJTqz
via IFTTT

Post a Comment

0 Comments