Here you can find the source of startWith(str)
String.prototype.startWith=function(str){ if(str==null||str==""||this.length==0||str.length>this.length) return false; if(this.substr(0,str.length)==str) return true; else //from w w w . j a va 2 s . co m return false; return true; }; String.prototype.endWith=function(str){ if(str==null||str==""||this.length==0||str.length>this.length) return false; if(this.substring(this.length-str.length)==str) return true; else return false; return true; }; function getK(num){ return Math.floor(num/1000); }
String.prototype.startWith = function (str) { var reg = new RegExp("^" + str); return reg.test(this);
String.prototype.startWith=function(str){ if(str==null||str==""||this.length==0||str.length>this.length) return false; if(this.substr(0,str.length)==str) return true; else return false; return true;
String.prototype.startWith = function(str) { var result = true; if (typeof(str)=='string' && str.length <= this.length) { for (var i=0,len=str.length;i<len;i++) { if (str.charAt(i) == this.charAt(i)) { continue; } else { result = false; break; ...
String.prototype.startWith = function(str) { var reg = new RegExp("^" + str); return reg.test(this); }; String.prototype.endWith = function(str) { var reg = new RegExp(str + "$"); return reg.test(this); };
String.prototype.startWith=function(str){ var reg=new RegExp("^"+str); return reg.test(this); String.prototype.endWith=function(str){ var reg=new RegExp(str+"$"); return reg.test(this);
String.prototype.startWith = function(substr) { return this.indexOf(substr) == 0; };
String.prototype.startWith = function (text) { return this.indexOf(text) == 0; }; var msg = "Hello world!"; console.log(msg.startWith("Hello"));
String.prototype.startWithVowel = function () { return this.charAt(0).toLowerCase().isVowel(); }; String.prototype.isVowel = function () { var vowels = ['a', 'e', 'i', 'o', 'u']; return vowels.indexOf(this.toLowerCase()) != -1; };
String.prototype.beginsWith = function( str ) { return this.substr( 0, str.length ) == str; };