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