This question already has an answer here:html
What is the best way to find if an object is in an array?java
This is the best way I know:jquery
function include(arr, obj) { for(var i=0; i<arr.length; i++) { if (arr[i] == obj) return true; } } include([1,2,3,4], 3); // true include([1,2,3,4], 6); // undefined