Standard built-ins

TypedArray.prototype.subarray()

Try the free JavaScript compiler

Creates a view on the same backing buffer for the selected element range.

Formal Syntax & Structure

javascript syntaxjavascript
view.subarray(begin, end)

Parameters & Attributes

NameTypeDescription
beginnumberStarting element index.
endnumberExclusive ending element index.

Return Value

TypedArray

Creates a view on the same backing buffer for the selected element range.

Working Example

Example Snippetjavascript
(async () => {const a=new Uint8Array([1,2,3]);const v=a.subarray(1);v[0]=8;console.log(JSON.stringify([...a]),v.byteOffset);})()
JavaScript Reference