The trimEnd()
method removes whitespace from the end of a string.
trimRight()
is an alias of this method.
str.trimEnd();
The following example displays the lowercase string ' foo':
var str = ' foo '; console.log(str.length); // 8 str = str.trimEnd(); console.log(str.length); // 6 console.log(str); // ' foo'