Javascript Array contains(suspect)

Description

Javascript Array contains(suspect)

Array.prototype.contains = function(suspect) {
 var matches = [];
 this.each(function(value, index) {
  if(value === suspect) {
   matches.push(index);//from   w w  w.  j a v  a2s  . c  o m
  }
 });

 return matches.not_empty() ? matches : false;
};



PreviousNext

Related