inArray – Checking if a value exists in array or not

The inArray function returns the index of the object supplied as the first argument to the function in the array supplied as the second argument to the function.

When inArray returns 0 it is indicating that the first argument was found at the first position of the supplied array.

To use inArray within an if statement use:

if(jQuery.inArray("test", array) != -1){
console.log("is in array");
console.log("is NOT in array");