JavaScript String trimStart() Tutorial

In this section, we will learn what the trimStart() method is and how to use it in JavaScript.

JavaScript String trimStart() Method (JavaScript Left Trim)

The `trimStart()` method is used to remove any white space from the beginning of a string value.

Note: this method won’t change the content of the original string value but creates a new one and returns that as a result.

JavaScript String trimStart() Syntax


String trimStart() Method Parameters:

This method does not take any argument.

String trimStart() Method Return Value:

The returned value of this method is a copy of the target string value with the white spaces removed from the start side.

Example: remove space from start of a string in JavaScript

const message = " Hello World! ";

const res = message.trimStart();

console.log(`The value is: ${res}***`);


The value is: Hello World! ***

As you can see, only the white space from the start side of the value in the `message` identifier is removed.

Leave a Reply