The trimRight()
method removes whitespace from the right end of a string.
str.trimRight()
The trimRight()
method returns the string stripped of whitespace from its right end. trimRight()
does not affect the value of the string itself.
trimRight()
The following example displays the lowercase string ' foo'
:
var str = ' foo '; console.log(str.length); // 8 str = str.trimRight(); console.log(str.length); // 5 console.log(str); // ' foo'
[Not part of any standard. Implemented in JavaScript 1.8.1.]
Created by Mozilla Contributors and licensed under CC-BY-SA 2.5