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.

    • Optionalguard: any

    Returns string

    Returns the trimmed string.

    5.6.0

    [[trimEnd]],[[trimStart]]

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

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