How to Check If Value Exists in a Javascript Array

In this example, we will show you how to check if the value exists in a javascript array. there are three types of checks if a value exists in a javascript array. so let’s go see three types.

You can use indexOf() function for check the value exists in an array or no. it is function returns the true and false value. see below example of indexOf().

You can use includes() function for check the value exists in an array or no. it is function returns the true and false value. see below example of includes().

 

Finally, You can use the inArray() function for check the value exists in an array or no. it is function returns the true and false value. see below example of inArray().

Leave a Reply

Your email address will not be published. Required fields are marked *