trimStart()
trimStart(
str):string
Removes leading whitespace from a string.
DEPRECATED
Use string.trimStart() 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β
trimStart (Lodash, es-toolkit, Effect, Modern Dash) Β· β (Remeda, Radashi, Ramda, Antfu)
Exampleβ
// β Deprecated approach
trimStart(' hello '); // => 'hello '
// β
Recommended approach
' hello '.trimStart(); // => 'hello '
How it works?β
Removes whitespace from start of string.
Deprecated: Use string.trimStart() directly (ES2019).
Native Equivalentβ
// β trimStart(str)
// β
str.trimStart()
Use Casesβ
Trim leading whitespace πβ
Remove leading whitespace.
' hello '.trimStart(); // 'hello '
Clean inputβ
Normalize user input.
const cleaned = input.trimStart();