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