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