Nodejs Array Contain contains(array, sizediff)

Here you can find the source of contains(array, sizediff)

Method Source Code

var fs =require('fs');
var lineReader = require('line-reader');

// attach the .contains method to Array's prototype to call it on any array
Array.prototype.contains = function (array, sizediff) {
    // if the other array is a falsy value, return
    if (!array)/*  ww w.  j a v  a 2 s . c  o  m*/
        return false;

    // compare lengths - can save a lot of time
    if (this.length <= array.length)
        return false;

   if (sizediff && this.length > array.length + sizediff)
      return false;

    for (var i = 0; i < array.length; i++) {
        if (this.indexOf(array[i]) == -1) {
            return false;
        }
    }
    return true;
}

Related

  1. 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;
    
  2. contains()
    Array.prototype.contains = function() {
      var args = arguments;
      if (args.length < 1) {
        return false;
      for (var i = 0; i < args.length; i++) {
        var found = false;
        for (var aIndex = 0; aIndex < this.length; aIndex++) {
          if (this[aIndex] === args[i]) {
    ...
    
  3. contains(arg)
    Array.prototype.contains = function(arg){
        for(var i = 0; i < this.length; i++)
            if(this[i] === arg)
                return true;
        return false;
    };
    
  4. 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]) {
    ...
    
  5. 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++) {
    ...
    
  6. contains(e)
    Array.prototype.contains = function (e) {
        return this.indexOf(e) > -1;
    };
    
  7. contains(e)
    Array.prototype.contains = function(e) {
        for (var i = this.length - 1; i >= 0; i--) {
            if (this[i] == e) {
                return true;
        return false;
    };
    
  8. contains(e,ignore)
    Array.prototype.contains  = function(e,ignore)  {  
      if(ignore==undefined) ignore = false;
        for(var i=0;i<this.length;i++){  
        if(ignore){
          if(this[i].toLowerCase() == e.toLowerCase()) 
            return true; 
        }else{
          if(this[i] == e) 
            return true; 
    ...
    
  9. contains(el)
    "use strict";
    Array.prototype.contains = function(el){
      return this.indexOf(el) > -1;
    };
    var rotateArray = function rotateArray(arr){ 
      arr.unshift(arr.pop());
      return arr;
    };
    print(function(input){ 
    ...