![]() ![]() This is why blank spaces count as part of the pattern to detect, and why it is possible to search for fractions of words – or even single characters, as seen below: console.log(str.includes('u')) The includes() method searches strings using character combination matches. Blank spaces are also taken into account when searching a String or an Array. 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. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |