Function endsWith

  • Checks if string ends with the given target string.

    Parameters

    • str: string

      The string to inspect.

    • target: string

      The string to search for.

    • position: number = str.length

      The position to search up to.

    Returns boolean

    Returns true if string ends with target, else false.

    Since

    5.7.0

    See

    [[includes]],[[startsWith]]

    Example

    endsWith('abc', 'c')
    // => true

    endsWith('abc', 'b')
    // => false

    endsWith('abc', 'b', 2)
    // => true