lastOr
ts
function Array.lastOr<T, U>(
target: readonly T[],
or: U,
): Exclude<T, null | undefined> | UReturns the last element of array, or fallback if the array is empty.
Example
ts
import { Array } from "@monstermann/array";
Array.lastOr([1, 2, 3, 4], 0); // 4ts
import { Array } from "@monstermann/array";
pipe([1, 2, 3, 4], Array.lastOr(0)); // 4