Nodejs String Contains contains(token, ignoreCase)

Here you can find the source of contains(token, ignoreCase)

Method Source Code

String.prototype.contains = function(token, ignoreCase) {
   var _reg = 0, str = this.toString(), i;
   if(str && typeof token === "string") {
      if(ignoreCase === true) {
         token = token.toLowerCase();//from  w ww.  jav  a2  s  .  c om
         str = str.toLowerCase();
      }
      while((i = str.indexOf(token)) !== -1) {
         str = str.substring(i + token.length);
         _reg++;
      }
   }
   return _reg;
};

Related

  1. contains(substring)
    String.prototype.contains = function(substring) {
      return this.indexOf(substring) != -1;
    
  2. contains(substring, ignoreCase)
    String.prototype.contains = function(substring, ignoreCase) {
      var lowerSubString = substring.toLowerCase(),
      lowerThis = this.toLowerCase();
      if (ignoreCase) {
        return lowerThis.indexOf(lowerSubString) > -1;
      } else {
        return this.indexOf(substring) > -1;
    
  3. contains(t)
    String.prototype.contains = function (t) {
        return this.indexOf(t) != -1;
    };
    
  4. contains(term)
    String.prototype.contains = function(term){
      return this.indexOf(term) > -1;
    };
    
  5. contains(text)
    String.prototype.contains = function (text) {
        return this.toLowerCase().indexOf(text.toLowerCase()) !== -1;
    };
    
  6. contains(txt)
    String.prototype.contains = function(txt)
        return (this.indexOf(txt) >= 0);
    
  7. contains(value)
    String.prototype.contains = function (value) {
        "use strict";
        var containsValue = false;
        if (this.indexOf(value) >= 0) {
            containsValue = true;
        return containsValue;
    };
    
  8. containsAll(strings, index)
    String.prototype.containsAll = function(strings, index) {
      if(!Array.isArray(strings)) throw Error('1 argument is not an array');
      return strings.every(string => this.includes(string, index), this);
    
  9. contains(substring)
    String.prototype.contains = function contains(substring) {
      return this.indexOf(substring) !== -1;
    };