JavaScript String trimEnd() Tutorial

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

JavaScript String trimEnd() Method

The `trimEnd()` method is used to remove any white spaces from the end of a string value.

Note: this method does not change the original content but creates a new one and returns that as a result.

JavaScript String trimEnd() Syntax


String trimEnd() Method Parameters:

This method does not take any argument.

String trimEnd() Method Return Value:

The returned value of this method is a copy of the original string value (the one that method invoked on) without any white spaces from the end of this result string value.

Example: using String trimEnd() method in JavaScript

const message = " Hello World! ";

const res = message.trimEnd();

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


The value is: Hello World!***


Top Technologies