JavaScript Remove Whitespace from End of String

Remove whitespace from end of string javascript; In this tutorial, i am going to show you how to remove whitespace from end of string javascript using String trimEnd() method.

JavaScript Remove Whitespace from End of String

Using the javascript string trimEnd() method, you can remove the whitespace characters from the end of a string.

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

Syntax of javascript string trimEnd() method is following:

let str1 = str.trimEnd();

Here,

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

Example – JavaScript Remove Whitespace from End of String

The following example demonstrates, how to remove whitespace characters from the beginning of a given string using trimEnd(), see the following example:

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

Output:

{result: "   JavaScript programming"}

Conclusion

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

More JavaScript Tutorials

Be First to Comment

Leave a Reply

Your email address will not be published.