In this tutorial, I show how you can check whether an Array already contains a specific value or not using Javascript and jQuery.
This requires within the program in some cases like –
- Stop new value from insert if it already exists in an Array.
- Execute script when the Array contains a particular value.
- etc.
If you are familiar with PHP, where you can use the in_array() function to search value in the Array, and it returns the Boolean value ( TRUE or FALSE ).
There are inbuilt methods in jQuery and JavaScript that return the index position of the value which you can use for the search.