trimStart()

ES2019+

Removes whitespace from the beginning of a string.

Syntax

string.trimStart()

Return Value

string

A new string with whitespace removed from the start

Examples

JavaScript
const str = '   Hello';
console.log(str.trimStart());
Output:
// 'Hello'

Related Methods