Nodejs Array Contain contains()

Here you can find the source of contains()

Method Source Code

Array.prototype.contains = function() {
   var args = arguments;
   if (args.length < 1) {
      return false;
   }/*w  w  w  . java2s .c o m*/
   for (var i = 0; i < args.length; i++) {
      var found = false;
      for (var aIndex = 0; aIndex < this.length; aIndex++) {
         if (this[aIndex] === args[i]) {
            found = true;
            break;
         }
      }
      if (found) {
         return true;
      }
   }
   return false;
};

Related

  1. contains( func)
    Array.prototype.contains = function( func) {
      if( $.isFunction(func) ) {
        for( var i=0; i<this.length; i++ ) {
          var item = this[i];
          if( func(item) == true ) {
            return true;
        return false;
    ...
    
  2. contains( needle )
    Array.prototype.contains = function ( needle ) {
        for (i in this) {
            if (this[i] == needle) return true;
        return false;
    
  3. contains( needle )
    Array.prototype.contains = function ( needle ) {
       for (i in this) {
           if (this[i] == needle) return true;
       return false;
    
  4. contains( needle )
    Array.prototype.contains = function ( needle ) {
       for (i in this) {
           if (this[i] === needle) return true;
       return false;
    
  5. contains( v )
    Array.prototype.contains = function( v ) {
      for ( var i = 0, l = this.length; i < l; i++ ) { 
        if ( this[ i ] === v ) return true; 
      return false;
    
  6. contains(arg)
    Array.prototype.contains = function(arg){
        for(var i = 0; i < this.length; i++)
            if(this[i] === arg)
                return true;
        return false;
    };
    
  7. contains(array)
    Array.prototype.contains = function(array) {
      var arr1 = this.sort();
      var arr2 = array.sort();
      var i = arr1.length;
      if ( i < arr2.length ) {
        return false;
      while (i--) {
        if (arr1[i] === arr2[i]) {
    ...
    
  8. contains(array)
    Array.prototype.contains = function (array) {
        var debug = true;
        var starts = [];
        for (var i = 0; i < this.length; i++) {
      if (this[i] == array[0])
          starts.push(i);
        console.log('found', starts.length, 'possible matches');
        for (var p = 0; p < starts.length; p++) {
    ...
    
  9. contains(array, sizediff)
    var fs =require('fs');
    var lineReader = require('line-reader');
    Array.prototype.contains = function (array, sizediff) {
        if (!array)
            return false;
        if (this.length <= array.length)
            return false;
      if (sizediff && this.length > array.length + sizediff)
        return false;
    ...