Nodejs Array In inArray(find, option)

Here you can find the source of inArray(find, option)

Method Source Code

/**//from   w  ww  . j  ava  2s .co m
 * Array prototype sets.
 *
 * A boy IRC bot, Marcas.
 */

/**
 * Array.prototype.inArray   Returns true if find is in the array.
 * @param  {String} find   String to find
 * @return {boolean}
 */
Array.prototype.inArray = function (find, option) {
    var length = this.length;

    for (var i = 0; i < length; i++) {
        if (option == "case-insensitive") {
            if (this[i].toLowerCase() == find.toLowerCase()) {
                return true;
            }
        }
        if (this[i] == find) {
            return true;
        }
    }

    return false;
};

Related

  1. inArray(comparer)
    Array.prototype.inArray = function(comparer) {
      for (var i = 0; i < this.length; i++) {
        if (comparer(this[i])) return true;
      return false;
    };
    Array.prototype.pushIfNotExist = function(element, comparer) {
      if (!this.inArray(comparer)) {
        this.push(element);
    ...
    
  2. inArray(comparer)
    Array.prototype.inArray = function(comparer) { 
        for(var i=0; i < this.length; i++) { 
            if(comparer(this[i])) return true; 
        return false; 
    };
    
  3. inArray(e)
    Array.prototype.inArray = function(e) {
        for (var i in this){
            if (this[i]===e) return true;
        return false;
    
  4. inArray(e)
    Array.prototype.inArray = function(e) {
      var length = this.length;
      for (var i = 0; i < length; i++) {
        if (this[i] == e)
          return true;
      return false;
    };
    
  5. inArray(element)
    Array.prototype.inArray = function (element) {
      for (var i = 0; i < this.length; i++) {
        if (this[i] == element) {
          return i;
      return -1;
    };
    
  6. inArray(i)
    Array.prototype.inArray= function(i){
        var _this = this;
        for(var x=0; x<_this.length; x++){
            if(_this[x]==i) return x;
        return -1;
    
  7. inArray(item)
    Array.prototype.inArray = function(item) {
      for(var i=0; i < this.length; i++) {
        if(item === this[i]) return true;
      return false;
    };
    
  8. inArray(needle)
    Array.prototype.inArray=function(needle){
        for(var i=0;i<this.length;i++){
          if(this[i]===needle){
            return true;
        return false;
    var arr=["red","blue","yellow"];
    ...
    
  9. inArray(needle)
    Array.prototype.inArray = function(needle) {
            for(var i=0; i < this.length; i++) {
                    if(this[i] === needle) {
                            return true;
            return false;