Tutorials References Exercises Menu
Paid Courses

Node.js buffer slice() Method

❮ Buffer Module


Make a new buffer, based on parts from an existing bufffer:

var x = Buffer.from('abcdef');
var y = x.slice(2,5);

Run example »

Definition and Usage

The slice() method returns a new buffer object, using parts of an existing buffer.

The start and end parameters specifies where to start and end the extraction.


buffer.slice(start, end);

Parameter Values

Parameter Description
start Optional. Where to start slicing. Default 0
end Optional. Where to end the slice, default at the very end of the buffer

 Technical Details

Return Value: A Buffer
Node.js Version: 0.3.0

❮ Buffer Module