Here you can find the source of ltrim()
// overload String Object String.prototype.ltrim = function() { //Match spaces at beginning of text and replace with a null string return this.replace(/^\s+/,''); }
String.prototype.ltrim = function() { return this.replace(/^\s+/g,"");
var s1 = new String(' A B '); String.prototype.ltrim = function(){ var regexp = /^\s*/; var result = this.replace(regexp, ''); return result; }; console.log('||'+s1.ltrim()+'||');
String.prototype.ltrim = function() { return this.replace(/^\s*/g,'');
String.prototype.ltrim=function() return this.replace(/(^\s*)/g,'');
String.prototype.ltrim = function() { return this.replace(/(^\s*)/g, "");
String.prototype.ltrim = function(){ return this.replace(/\s+$/, ""); };
String.prototype.ltrim = function(){ return this.replace(/^\s+/, ""); };
String.prototype.ltrim = function() return this.replace( /^\s*/g, '' ) ;
String.prototype.ltrim = function(){ var res = this; while (res.substring(0, 1) == " ") { res = res.substring(1, res.length); return res;