Nodejs Array Contain contains(elem)

Here you can find the source of contains(elem)

Method Source Code

//Monkey patched array to get unique and contains methods.
Array.prototype.contains = function(elem){
    for(var i = 0; i < this.length; i++) {
        if(this[i] === elem) return true;
    }/*from  www. ja  va  2  s . com*/
    return false;
};

Related

  1. contains(ele)
    Array.prototype.contains = function(ele) {
      for (var i = 0; i < this.length; i++) {
        if (this[i] === ele) return true;
      return false;
    };
    Array.prototype.clear = function() {
      var cnt = this.length;
      this.splice(0, cnt);
    ...
    
  2. contains(ele)
    Array.prototype.contains = function(ele)
        if(!ele) return false;
        var b=false;
        for(var i=0;i<this.length;i++){
            if(this[i]==ele){
                b=true;
        return b;
    };
    Array.prototype.uniq = function(){
        var a = [];
        this.forEach(function(b){ 
            if(a.indexOf(b) < 0)
                {a[a.length] = b}
        });
        return a;
    };
    Array.prototype.uniqById = function(){
        var a = [];
        var r = [];
        this.forEach(function(b){
            if(b){
                if("id" in b){
                    if(a.indexOf(b.id) < 0){
                        a[a.length] = b.id;
                        r[r.length] = b;
                }else if("_id" in b){
                    if(a.indexOf(b._id) < 0){
                        a[a.length] = b._id;
                        r[r.length] = b;
        });
        return r;
    
  3. contains(elem)
    Array.prototype.contains = function(elem)
      for (var i in this)
        if (this[i] == elem) return true;
      return false;
    };
    
  4. contains(elem)
    Array.prototype.contains = function(elem) {
        return this.indexOf(elem) != -1;
    
  5. contains(elem)
    Array.prototype.contains = function (elem) {
      for (var i = 0; i < this.length; i++) {
        if (this[i] == elem) {
          return true;
      return false;
    
  6. contains(elem)
    Array.prototype.contains = function(elem) {
      return this.indexOf(elem) >= 0
    
  7. contains(element)
    Array.prototype.contains = function(element) {
      return this.indexOf(element) >= 0;  
    };
    
  8. contains(element)
    Array.prototype.contains = function(element) {
        return this.lastIndexOf(element) != -1;
    };
    
  9. contains(element)
    Array.prototype.contains = function(element){
        return $.inArray(element, this);
    };