Function trim

  • Removes leading and trailing whitespace or specified characters from string.

    Parameters

    • str: string

      The string to trim.

    • chars: string

      The characters to trim.

    • Optional guard: any
      Optional

    Returns string

    Returns the trimmed string.

    Since

    5.6.0

    See

    [[trimEnd]],[[trimStart]]

    Example

    trim('  abc  ')
    // => 'abc'

    trim('-_-abc-_-', '_-')
    // => 'abc'