Javascript Array contains()

Description

Javascript Array contains()


Array.prototype.contains = function() {
 var args = arguments;
 if (args.length < 1) {
  return false;//  w w  w .  j  a v  a2 s .co  m
 }
 for (var i = 0; i < args.length; i++) {
  var found = false;
  for (var aIndex = 0; aIndex < this.length; aIndex++) {
   if (this[aIndex] === args[i]) {
    found = true;
    break;
   }
  }
  if (found) {
   return true;
  }
 }
 return false;
};



PreviousNext

Related