Here you can find the source of trim()
String.prototype.trim = String.prototype.trim || function() { return (this || '').replace(/^\s\s*/, '').replace(/\s\s*$/, ''); }; String.prototype.seconds = String.prototype.seconds || function() { return parseFloat(this) * 1000; } String.prototype.attempts = String.prototype.attempts || function() { return parseInt(this); } Math.getRandom = Math.getRandom || function(lower, upper) { if (upper < lower) return Math.getRandom(upper, lower); // swap back by calling in wrong order; return Math.floor(Math.random() * (upper - lower + 1)) + lower; }; Math.getIdentity = Math.getIdentity || function() { return new Date().getTime().toString() + Math.getRandom(1, 99999999).toString(); };
String.prototype.trim = function() { return this.replace(/^s+|s+$/, ?);
function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); function ltrim(stringToTrim) { return stringToTrim.replace(/^\s+/,""); function rtrim(stringToTrim) { return stringToTrim.replace(/\s+$/,""); String.prototype.trim = function() {return this.replace(/^\s+|\s+$/g,"");} String.prototype.ltrim = function() {return this.replace(/^\s+/,"");} String.prototype.rtrim = function() {return this.replace(/\s+$/,"");}
String.prototype.trim = function(){ if(/^([ | ]*)(.*)([ | ]*)$/.test(this)){ return RegExp.$2; return this; };
String.prototype.trim = function() { 'use strict'; return this.replace(/^\s+/,'').replace(/\s+$/,''); };
String.prototype.trim = function () { return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"); };
String.prototype.trim = function() { return this.replace(new RegExp('\n| ','g'), '');
String.prototype.trim = function () { return this.replace(/^\s*/, "").replace(/\s*$/, ""); };
String.prototype.trim = function(){ return this.replace(/^\s+|\s+$/g, '') String.prototype.ltrim = function(){ return this.replace(/^\s+/,'') String.prototype.rtrim = function(){ return this.replace(/\s+$/,'') String.prototype.fullTrim = function(){ return this.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,' ') String.prototype.byteLength = function(){ var count = 0; for(var i=0;i<this.length;i++) if(this.charCodeAt(i) >= 00000000 && this.charCodeAt(i) <= 0x0000007F) count++ else if(this.charCodeAt(i) >= 0x00000080 && this.charCodeAt(i) <= 0x000007FF) count += 2 else if(this.charCodeAt(i) >= 0x00000800 && this.charCodeAt(i) <= 0x0000FFFF) count += 3 else if(this.charCodeAt(i) >= 0x00010000 && this.charCodeAt(i) <= 0x001FFFFF) count += 4 return count
String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, ""); String.prototype.ltrim = function () { return this.replace(/^\s+/, ""); String.prototype.rtrim = function () { return this.replace(/\s+$/, ""); String.prototype.toStringWithCommas = function () { var parts = this.toString().split("."); parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); return parts.join("."); }; String.prototype.format = function () { var args = arguments; return this.replace(/{(\d+)}/g, function (match, number) { return typeof args[number] != 'undefined' ? args[number] : match ; }); };