Node.js buffer slice() Method
Example
Make a new buffer, based on parts from an existing bufffer:
var x = Buffer.from('abcdef');
var y = x.slice(2,5);
console.log(y.toString());
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.
Syntax
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 |