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