Nodejs Array Contain contains(value)

Here you can find the source of contains(value)

Method Source Code

"use strict";/*from   w w w.  java2s.c  o  m*/

Array.prototype.contains = function(value){
   var n = this.length
   for (var i = 0; i < n; i++){
      if (this[i] == value) return true
   }
   return false
}

Related

  1. contains(val)
    #!/usr/bin/js
    arr = [1, 2, 3, 4, 5];
    Array.prototype.contains = function (val) {
      for (var i = 0; i < this.length; i++){
        if (this[i] === val){
          return true;
    console.log(arr.contains(3))
    
  2. contains(value)
    Array.prototype.contains = function(value) {
      return this.indexOf(value) > -1;
    };
    
  3. contains(value)
    Array.prototype.contains = function (value){
        return this.indexOf(value)>=0
    };
    
  4. contains(value)
    Array.prototype.contains = function(value) {
        return Array.prototype.indexOf.call(this, value) !== -1;
    };
    
  5. contains(value)
    Array.prototype.contains = function(value) {
        return (this.indexOf(value) > -1);
    
  6. contains(value)
    Array.prototype.contains = function(value) {
      return this.indexOf(value) !== -1;
    };
    Array.prototype.remove = function(value) {
      var index = this.indexOf(value);
      if ( index !== -1 ) {
        this.splice(index, 1);
    };
    ...
    
  7. contains(value)
    Array.prototype.contains = function(value) {
      for(var i=0; i < this.length; i++) {
        if(this[i] === value)
              return true;
      return false;
    };
    
  8. contains(what)
    Array.prototype.contains = function (what) {
      var contains = false;
      if (typeof what !== 'function') {
        this.forEach(function (item) {
          if (contains) return;
          contains = (item === what);
        });
        return contains;
      this.forEach(function (item) {
        if (contains) return;
        contains = what(item);
      });
      return contains;
    };
    
  9. contains(x)
    Array.prototype.contains=function(x){
     for(i in this){
       if((x.city==this[i].city || x.firstName==this[i].firstname || x.lastName==this[i].lastname))
         return true;
     return false;