Skip to main content

trimEnd()

trimEnd(str): string

Removes trailing whitespace from a string.

DEPRECATED

Use string.trimEnd() directly instead.


Parameters​

str: string | null | undefined​

The string to trim.


Returns: string​

The trimmed string.


See Also​


Since​

2.0.0


Also known as​

trimEnd (Lodash, es-toolkit, Effect, Modern Dash) · ❌ (Remeda, Radashi, Ramda, Antfu)


Example​

// ❌ Deprecated approach
trimEnd(' hello '); // => ' hello'

// βœ… Recommended approach
' hello '.trimEnd(); // => ' hello'

How it works?​

Removes whitespace from end of string. Deprecated: Use string.trimEnd() directly (ES2019).

Native Equivalent​

// ❌ trimEnd(str)
// βœ… str.trimEnd()

Use Cases​

Trim trailing whitespace πŸ“Œβ€‹

Remove trailing whitespace.

'  hello  '.trimEnd();  // '  hello'

Clean output​

Remove trailing spaces from output.

const cleaned = output.trimEnd();