The factory is not called for an existing entry. Unlike arrayGetOrExtend,
this accepts entries of any object type, including built-ins and class instances.
Example
constdates: Date[] = []; arrayGetOrExtendWith(dates, 1, (i) =>newDate(i)); // Date at timestamp 1
Gets the element at the given index, extending via a factory function if out of bounds.