Nodejs String Starts With startWith(str)

Here you can find the source of startWith(str)

Method Source Code

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;//ww  w . j  a va 2s .  com
         } else {
            result = false;
            break;
         }
      }
   } else {
      result = false;
   }
   return result;
}

Related

  1. startWith(s)
    function convertParamsMapToUri(paramsMap) {
        var uri = "";
        var isFirst = true;
        for (var key in paramsMap) {
            var keyValue = key + "=" + paramsMap[key];
            if (isFirst) {
                isFirst = false;
            } else {
                uri += "&";
    ...
    
  2. startWith(str)
    String.prototype.startWith = function(str){
      return this.indexOf(str) == 0;
    };
    
  3. startWith(str)
    String.prototype.startWith = function(str) {
      var reg = new RegExp("^" + str);
      return reg.test(this);
    };
    
  4. startWith(str)
    String.prototype.startWith = function (str) {
      var reg = new RegExp("^" + str);
      return reg.test(this);
    
  5. 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
      return false;
    return true;
    
  6. startWith(str)
    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);
    };
    
  7. startWith(str)
    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);        
    
  8. 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  
          return false;  
        return true;  
    };
    ...
    
  9. startWith(substr)
    String.prototype.startWith = function(substr) {
        return this.indexOf(substr) == 0;
    };