trimEnd

Removes whitespace from the right end of the str.

Usage Scenarios

  • Data Cleaning: In data processing, clean strings by removing trailing whitespace.
  • Input Validation: Validate user input by removing unnecessary whitespace.

Example

import { trimEnd } from 'funtool/string'

trimEnd('hello  '); // ✅ 'hello'
trimEnd(''); // ✅ ''
trimEnd(123) // => '123' ✅

Signature

function trimEnd(str: string): string

Parameters

  • str ( string ): The input string.

Returns

  • ( string ): A new string with trailing whitespace removed.