Standard built-ins

ArrayBuffer.prototype.slice()

Try the free JavaScript compiler

Copies bytes in the selected half-open interval to a separate buffer.

Formal Syntax & Structure

javascript syntaxjavascript
buffer.slice(start, end)

Parameters & Attributes

NameTypeDescription
startnumberBeginning byte offset.
endnumberExclusive 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)]));})()
JavaScript Reference