Skip to content

Instantly share code, notes, and snippets.

@YurePereira
Last active July 19, 2016 12:36
Show Gist options
  • Select an option

  • Save YurePereira/c0cb4a4c1ab05c2251f5b0c405c1df46 to your computer and use it in GitHub Desktop.

Select an option

Save YurePereira/c0cb4a4c1ab05c2251f5b0c405c1df46 to your computer and use it in GitHub Desktop.
/**
* Verifica se determinado valor (value) está dentro de um determinado Array (Vector).
*
* @param value Any Valor a ser pesquisado.
* @param vector Array Vetor onde será pesquisado um valor passado por parâmetro.
*/
function inArray(value, vector) {
var count = 0,
length = vector.length;
for (var i = 0; i < length; i++) {
count += value == vector[i] ? 1 : 0;
}
return count > 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment