Uint16Array.prototype.subarray

Returns a new Uint16Array view of the same backing ArrayBuffer for this typed array, referencing the elements starting from the specified starting index and up to, but not including, the specified ending index.

Syntax

subarray(start?, end?)

Parameters

Example

a = new Uint16Array([8, 16, 32, 64])
b = a.subarray(1, 3)
print("a:", a)
print("b:", b)
// Changing only a also affects b
// because they shared the same ArrayBuffer.
a[2] = 111
print("a:", a)
print("b:", b)
a: 8,16,32,64
b: 16,32
a: 8,16,111,64
b: 16,111