Skip to main content

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