Here you can find the source of trim()
String.prototype.trim = function(){ /*from www. j av a2 s. co m*/ var str = this.replace(/\s+/g,"") return this; }
String.prototype.trim = function() { try { return this.replace(/^\s+|\s+$/g, ""); } catch(e) { return this; };
String.prototype.trim = function() { return this.replace(/^[ ]+|[ ]+$/g, ''); };
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ""); };
'use strict'; String.prototype.trim = function(){ return this.replace(/(^\s*)|(\s*$)/g, "");
String.prototype.trim = function() return this.replace(/(^\s*)|(\s*$)/g, "");
$(document).ready(function(){ }); String.prototype.trim = function() { return this.replace(/(^\s*)|(\s*$)/g, '');
String.prototype.trim = function() { var x=this; x=x.replace(/^\s*(.*)/, "$1"); x=x.replace(/(.*?)\s*$/, "$1"); return x;
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(){ trimLeft = /^\s+/; trimRight = /\s+$/; return this.replace(trimLeft,"").replace(trimRight,""); };