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();