Nodejs Array Contain contains(obj)

Here you can find the source of contains(obj)

Method Source Code

/**//w ww  . j av  a  2  s  .co  m
 * @file Defines extra functions for the Array object not defined by Rhino.  NOT STANDARD ECMASCRIPT!!!
 * @author Tribex
 */

/**
 * Check if an array contains a value.
 * @param obj {object} The value to search the array for.
 * @returns {boolean} true if found, false if not.
 */
Array.prototype.contains = function(obj) {
    var i = this.length;
    //Supposedly the fastest way to iterate in JavaScript. May not be true for Rhino.
    while (i--) {
        if (this[i] == obj) {
            return true;
        }
    }
    return false;
}

Related

  1. contains(obj)
    'use strict';
    const list = require('./list.json');
    const items = [];
    const duplicates = [];
    Array.prototype.contains = function(obj) {
      let i = this.length;
      while (i--) {
        if (this[i] == obj) {
            return true;
    ...
    
  2. contains(obj)
    Array.prototype.contains = function(obj) {
      let i = this.length;
      while (i--) {
        if (this[i] == obj) {
            return true;
      return false;
    
  3. contains(obj)
    Array.prototype.contains = function(obj){
      return this.indexOf(obj)>-1;
    };
    
  4. contains(obj)
    Array.prototype.contains = function(obj) {
        var i = this.length;
        while (i--) {
            if (this[i] === obj) {
                return true;
        return false;
    };
    ...
    
  5. contains(obj)
    Array.prototype.contains = function (obj) {
        return this.indexOf(obj) >= 0;
    };
    
  6. contains(obj)
    Array.prototype.contains = function (obj) {
        var i = this.length;
        while (i--) {
            if (this[i] === obj) {
                return true;
        return false;
    
  7. contains(obj)
    Array.prototype.contains = function(obj) {
        var i = this.length;
        while (i--) {
            if (this[i] === obj) {
                return true;
        return false;
    };
    ...
    
  8. contains(obj)
    Array.prototype.contains=function(obj) {
        var index=this.length;
        while (index--){
            if(this[index]===obj){
                return true;
        return false;
    
  9. contains(obj)
    Array.prototype.contains = function(obj) {
        var i = this.length;
        while (i--) {
            if (this[i] === obj) {
                return true;
        return false;
    if (!String.prototype.startsWith) {
      String.prototype.startsWith = function(searchString, position) {
        position = position || 0;
        return this.indexOf(searchString, position) === position;
      };
    String.prototype.arrayfy = function(n) {
      arr = this.split(' ');
      return arr.slice(0,n);
    window.required = [];
    window.require = function(script, callback) {
      if(!required.contains(script))
        $.get(script + ".js", function(data){
          required.push(script);
          eval(data);
          if(callback != null)
            callback();
        });