JS Built-ins
TypedArraysubarrayintermediate

TypedArray.prototype.subarray()

πŸ“– Usage Example
const arr = new Int32Array([1, 2, 3, 4, 5]);
const sub = arr.subarray(1, 3);
// Int32Array [2, 3] (same underlying buffer)

subarray() returns a view of a portion without copying the underlying buffer.

Use subarray() to get a view of a portion of a typed array without copying.

πŸ’‘ Hints (1)
  • β€’ subarray(start, end) returns a view, not a copy