Tuesday, 18 April 2017

I need help in understanding the node.js buffertools array

I am using following npm package. I have following code

var buffertools = require('buffertools');
var buf = new Buffer(42);
console.log(buf);
for(var i=0; i<42; i++){
console.log(buf[i]);
}

The output of the code is

<Buffer 00 00 00 00 00 00 00 00 2a 4c a8 64 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>

and output of loop is

0 0 0 0 0 0 0 0 42 76 168 100 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

I can understand that 2a is hexadecimal and its decimal 42 is coming in the output of loop. I am interested in why and how this value down below is generated?

<Buffer 00 00 00 00 00 00 00 00 2a 4c a8 64 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00>



via Human Love

No comments:

Post a Comment