JavaScript Remove Whitespace from Start of String

To remove whitespace from beginning of string javascript;Through this tutorial, i am going to show you how to remove whitespace from beginning/starting of string javascript with the help of trimStart() method.

JavaScript Remove Whitespace from Start of String

Using the javascript string trimStart() method; you can remove the whitespace characters from the beginning of a string.

Here, i will show you syntax and parameters of trimStart() method; as follows:

Syntax of javascript string trimStart() method is following:

let str1 = str.trimStart();

Here,

  • The trimStart() method doesn’t change the given string.

Example – To Remove Whitespace from Start of String in JavaScript

Let’s take an example for remove whitespace characters from the beginning of a given string using trimStart(); as follows:

let str = '   JavaScript programming  ';
let result = str.trimStart();
console.log({ result });

Output of the above code is; as follows:

{result: "JavaScript programming  "}

Conclusion

In this tutorial, you have learned how to remove whitespace characters from the beginning of string using the js trimStart() method.

More JavaScript String Tutorials

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *