String.prototype.trimRight()
This function interprets a string value as a sequence of code points, as described in 6.1.4.
The following steps are taken:
- Let O be
CheckObjectCoercible(this value)
. - Let S be
ToString(O)
. - ReturnIfAbrupt(S).
- Let T be a String value that is a copy of S with trailing white space removed. The definition of white space is the union of WhiteSpace and )LineTerminator. When determining whether a Unicode code point is in Unicode general category “Zs”, code unit sequences are interpreted as UTF-16 encoded code point sequences as specified in 6.1.4.
- Return T.
NOTE The trimRight
function is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
String.prototype.trimLeft()
This function interprets a string value as a sequence of code points, as described in 6.1.4.
The following steps are taken:
- Let O be
CheckObjectCoercible(this value)
. - Let S be
ToString(O)
. - ReturnIfAbrupt(S).
- Let T be a String value that is a copy of S with leading white space removed. The definition of white space is the union of WhiteSpace and )LineTerminator. When determining whether a Unicode code point is in Unicode general category “Zs”, code unit sequences are interpreted as UTF-16 encoded code point sequences as specified in 6.1.4.
- Return T.
NOTE The trimRight
function is intentionally generic; it does not require that its this value be a String object. Therefore, it can be transferred to other kinds of objects for use as a method.
👍