trimEnd method
The trimEnd method removes
whitespaces at the end of a string and
returns a new string without
changing the original string.
Syntax
javascriptstring.trimEnd();
Example
Let's remove the extra spaces
in the string ' abcde ':
javascriptlet res = ' abcde '.trimEnd();
console.log(res);
As a result of executing the code, we will see that there are no spaces at the end of the string:
javascript' abcde'