Nodejs Array In in_array(value, caseSensitive)

Here you can find the source of in_array(value, caseSensitive)

Method Source Code

/*/* ww w.j a va 2s.  c  om*/
 * @ref http://www.guyfromchennai.com/?p=28
 * @author Kumar S.
 * Returns true if the passed value is found in the
 * array. Returns false if it is not.
 */
Array.prototype.in_array = function(value, caseSensitive)
{
   for(var i=0; i < this.length; i++)
   {
      // use === to check for Matches. ie., identical (===),
      if(caseSensitive)
      { //performs match even the string is case sensitive
         if(this[i].toLowerCase() == value.toLowerCase())
         {
            return true;
         }
      }
      else
      {
         if(this[i] == value)
         {
            return true;
         }
      }
   }
   
   return false;
};

/*
 * @author John Resig
 * @license MIT
 */
Array.prototype.remove = function(from, to)
{
   var rest = this.slice((to || from) + 1 || this.length);
   this.length = from < 0 ? this.length + from : from;
   return this.push.apply(this, rest);
};

Related

  1. in_array(e)
    Array.prototype.in_array = function(e){
      for (var i = 0; i < this.length; i++) {  
            if (this[i] == e) {  
                return true;  
        return false;
    
  2. in_array(entity)
    Array.prototype.in_array = function(entity) {
        for (var idx in this) {
            if (this[idx] === entity)
                return true;
        return false;
    };
    
  3. in_array(needle)
    Array.prototype.in_array = function(needle) {
      for (var i = 0; i < this.length; i++)
        if (this[i] === needle)
          return true;
      return false;
    
  4. in_array(value)
    Array.prototype.in_array = function (value) {
      return (this.indexOf(value) !== -1);
    };
    
  5. in_array(value)
    Array.prototype.in_array = function(value){
        var len = this.length,
            i;
        for(i = 0;i < len;i+=1){
            if(this[i] === value) return i;
        return false;
    
  6. isIn(key, value)
    Array.prototype.isIn = function(key, value) {
        for(var i =0; i<this.length; i++) {
            if(this[i][key] == value) {
                return true;
        return false;
    };
    
  7. isInArray(elem)
    Array.prototype.isInArray = function (elem) {
        for (i = 0, len = this.length; i < len; i++) {
            if (this[i] == elem) {
                return true;
        return false;