str.includes() function is used to check if the argument string is present in the given string or not. This function is case sensitive. The syntax of this function is as follows:
Arguments The first argument to this function searchString is the string to be searched in the given string. The second argument to this function position determines the starting index in the base string from where the searchString is to be searched.
Examples for the above function are provided below:
print('Departed Train'.includes('ed Trai'));
In this example the function includes() searches for ed Trai. Since it is found in the given string therefore this function returns true.
In this example the function includes() searches for train. Since it is not found in the given string therefore this function returns false.
In this example the function includes() searches for Train. Since it is found in the given string therefore this function returns true.
Codes for the above function are provided below:
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.