You can use the indexOf () method of an array. If the return value is-1, it means it does not exist; if the return value is an integer greater than-1, it means it exists. For example:
var arr =;
arr . index of( 1); //Returns 0
arr . index of(5); //Return - 1
Attachment: The return value is the position of the foremost element in the array.