Standard built-ins
ArrayBuffer.prototype.slice()
Copies bytes in the selected half-open interval to a separate buffer.
Formal Syntax & Structure
javascript syntaxjavascript
buffer.slice(start, end)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| start | number | Beginning byte offset. |
| end | number | Exclusive end byte offset. |
Return Value
ArrayBuffer
Copies bytes in the selected half-open interval to a separate buffer.
Working Example
Example Snippetjavascript
(async () => {const a=new Uint8Array([1,2,3]);const c=a.buffer.slice(1,3);a[1]=9;console.log(JSON.stringify([...new Uint8Array(c)]));})()