Skip to content

lastIndexOfOr

Array.lastIndexOfOr(target, value, or)

Returns the index of the last occurrence of value in target. If value is not found, returns or.

Example

ts
import { Array } from "@monstermann/array";

Array.lastIndexOfOr([1, 2, 3, 2], 2, -1); // 3
Array.lastIndexOfOr([1, 2, 3], 4, -1); // -1
ts
import { Array } from "@monstermann/array";

pipe([1, 2, 3, 2], Array.lastIndexOfOr(2, -1)); // 3
pipe([1, 2, 3], Array.lastIndexOfOr(4, -1)); // -1