Note: The indexOf() method is case sensitive!
Note: If the string value to be retrieved is not present, the method returns -1.
Specific usage:
First create an html file and add the following code:
Then run the html file in the browser
Finally check the running results, “-1” means that this value does not exist;
Related reference:JS Tutorial
The above is the detailed content of JS judging whether an array contains a certain value. For more information, please pay attention to other related articles on 1024programmer.com !