Check if a value exists in an array - Node.js Array

Node.js examples for Array:Array Value

Description

Check if a value exists in an array

Demo Code

Array.prototype.exist = function(el) {
  for (var i = 0; i < this.length; i++)
    if (this[i] == el)
      return i;/*from   ww w .java 2  s.c om*/
  return -1;
};

Related Tutorials