Function endsWith

Checks if a value is the end of a source array or string.

endsWith('c')('abc'); // => true
endsWith('b')('abc'); // => false
endsWith('c')(['a', 'b', 'c']); // => true
endsWith('b')(['a', 'b', 'c']); // => false
endsWith('a', 1)('abc'); // => true
endsWith('a', 2)('abc'); // => false
endsWith('a', 1)(['a', 'b', 'c']); // => true
endsWith('a', 2)(['a', 'b', 'c']); // => false
  • Type Parameters

    • V

    Parameters

    • search: V

      The value to search for.

    • OptionalendIndex: number

      Search starts at endIndex – length.

    Returns (
        source: V extends string
            ? readonly unknown[]
            | V<V>
            : readonly unknown[],
    ) => boolean