Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Allocate buffer of size 15 filled with 'b'
- const bufferAlloc = Buffer.alloc(15, 'b');
- // Create buffer1 with 'hello' and buffer2 with 'world'
- const buffer1 = Buffer.from('hello');
- const buffer2 = Buffer.from('world');
- // Combine buffer1 and buffer2
- const bufferArray = [buffer1, buffer2]
- const bufferConcat = Buffer.concat(bufferArray);
- // Translate buffer to string
- const bufferString = bufferConcat.toString();
- console.log(bufferAlloc); // will print 62 hexadecimal code for letter 'b'
- console.log('Buffer 1:', buffer1, 'Buffer 2:', buffer2) // each printed represents the hexadecimal of the letters
- console.log(bufferConcat);
- console.log(bufferString); //then show the words combined in string form
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement