Element type.
The element at index.
Scalars (including null and undefined) are stored unchanged. For objects, copies
array elements or enumerable own record properties, retaining nested references.
Object templates must have this realm's Object.prototype or Array.prototype, or a null
prototype for records. Null-prototype records retain their null prototype. Existing
entries are returned without inspecting the template. Use arrayGetOrExtendWith
for built-ins, class instances, or templates from another realm.
const rows: number[][] = [];
arrayGetOrExtend(rows, 1, [0]); // [0]; rows is [[0], [0]]
rows[0]!.push(1); // rows[1] remains [0]
const values: bigint[] = [];
arrayGetOrExtend(values, 2, 4n); // 4n; values is [4n, 4n, 4n]
arrayGetOrExtend([], 0, "foo"); // "foo"
arrayGetOrExtend([], 0, null); // null
Gets an element, extending with scalar values or shallow copies if out of bounds.