A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer/slice below:

ArrayBuffer.prototype.slice() - JavaScript | MDN

ArrayBuffer.prototype.slice()

Baseline Widely available

The slice() method of ArrayBuffer instances returns a new ArrayBuffer whose contents are a copy of this ArrayBuffer's bytes from start, inclusive, up to end, exclusive. If either start or end is negative, it refers to an index from the end of the array, as opposed to from the beginning.

Try it
// Create an ArrayBuffer with a size in bytes
const buffer = new ArrayBuffer(16);
const int32View = new Int32Array(buffer);
// Produces Int32Array [0, 0, 0, 0]

int32View[1] = 42;
const sliced = new Int32Array(buffer.slice(4, 12));
// Produces Int32Array [42, 0]

console.log(sliced[0]);
// Expected output: 42
Syntax
slice()
slice(start)
slice(start, end)
Parameters
start Optional

Zero-based index at which to start extraction, converted to an integer.

end Optional

Zero-based index at which to end extraction, converted to an integer. slice() extracts up to but not including end.

Return value

A new ArrayBuffer containing the extracted elements. It is not resizable, even if the original was.

Examples Copying an ArrayBuffer
const buf1 = new ArrayBuffer(8);
const buf2 = buf1.slice(0);
Specifications Browser compatibility See also

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4