JavaScript .trim()was defined in ES 5.1 and will not work for IE <9 . Therefore, if you are already using jQuery, you can use a less efficient$.trim()
jQuery $.trim() Method does:
trim: function( text ) {
return text == null ? "" : ( text + "" ).replace( rtrim, "" );
}
where rtrimbasically is RegExp
new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" )
and whitespaceis represented as this group:
"[\\x20\\t\\r\\n\\f]"
In JavaScript (ES6), it is defined as:21.1.3.25 String.prototype.trim ()
String UTF-16, 6.1.4.
: O - ( ). S - ToString (O). ReturnIfAbrupt (S). T - String, S , . - WhiteSpace LineTerminator. , Unicode "Zs", UTF-16, 6.1.4. . ; , String. .
JS .trim() , :
.