

Searching for “Includes” with a capital I will return false. Important: includes() is case sensitive!!

As the value of const str contains the search string (included as the character combination i-n-c-l-u-d-e-s), the method returns true. In the example above, the includes() method is used to search the string variable const str for the word “ includes”. The following example demonstrates basic usage of includes() when working with a String: const str = 'This String includes the word includes' This article introduces the basics of the includes() method for each prototype, as well as exploring the differences between the two. This method accepts a search value as a parameter, and returns true if the value is either contained in the array on which it is called, or if it exists as a substring of the string object on which it is called. The includes() method is part of both the Array and String prototypes.
