UNB/ CS/ David Bremner/ teaching/ cs2613/ books/ mdn/ Reference/ Global Objects/ ArrayBuffer/ ArrayBuffer.prototype.slice()

The slice() method of ArrayBuffer instances returns a new ArrayBuffer whose contents are a copy of this ArrayBuffer's bytes from begin, inclusive, up to end, exclusive.

Syntax

slice()
slice(start)
slice(start, end)

Parameters

Return value

A new ArrayBuffer object.

Examples

Copying an ArrayBuffer

const buf1 = new ArrayBuffer(8);
const buf2 = buf1.slice(0);

Specifications

Browser compatibility

See also