
Then use includes() to check if the string "thick scales" exists in the array: alligatorFacts. Here is a sample array of alligator facts: const alligatorFacts = The default is 0, so the entire array is searched. The second parameter, fromIndex, is optional and sets the index from which to begin comparisons. The first parameter, valueToFind, is the value to match in the array. The includes() method returns either a true or a false if a value exists in an array or not. If you would like to follow along with this article, you will need:

In this article, you will learn about Array.includes(), Array.indexOf, Array.find(), and Array.filter. Now there are several built-in utility methods that solve some of the common tasks for searching for values in an array. Prior to ECMAScript 6, you probably would have used a for loop to iterate through all the items in the array and perform operations on each item. Depending on the task at hand, you may be interested in a boolean value for confirmation, an index for the position of the value in the array, or a separate array containing all the search results.

A common task will be searching the array to find if it contains a value (or values) that satisfies certain search criteria. In JavaScript, you will often be working with data that is stored in Arrays.
