consider below code
var fruits = ["Banana", "Orange", "Apple", "Mango"]; var index = fruits.indexOf("Apple"); if(index===index != -1) { alert ("Apple found at " + index) } else { alert ("Apple not in exists") } array indexof returns index number(0 or 1 or 2) of the value if the value exists but returns -1 if the value does not exists.
thanks!