Javascript Array inArray() method

Description

Javascript Array inArray() method


"use strict";/*from  w w w  .j a  v a2  s  . c o  m*/


Array.prototype.inArray = function()
{
    for (var j in this) {
        if (this[j] == arguments[0]) {
            return true;
        }
    }

    return false;
}

Javascript Array inArray()

/**//from  w  w  w. j a  v  a  2 s. com
 *  Checks if a value exists in an array
 *
 *  @param array key
 *  @return Returns true if needle is found in the array, false otherwise
 */
Array.prototype.inArray = function()
{ 
  for (var j in this) { 
    if (this[j] == arguments[0]) { 
      return true;
    } 
  }

  return false;     
}



PreviousNext

Related