Standard built-ins

TypedArray.prototype.slice()

Try the free JavaScript compiler

Copies selected elements into a new typed array under ordinary default construction.

Formal Syntax & Structure

javascript syntaxjavascript
view.slice(begin, end)

Parameters & Attributes

NameTypeDescription
beginnumberStarting element index.
endnumberExclusive ending element index.

Return Value

TypedArray

Copies selected elements into a new typed array under ordinary default construction.

Working Example

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