![]() Specifying Multiple Characters as the Substringįinally, the includes() method can search for multiple characters in a string.Ĭonsole.log(totn_string.includes('The')) So in this case, the includes() method returned false because the substring 'e' is not found. This means that the search will begin looking for the value 'e' starting at position 11 in the string 'TechOnTheNet'. In this example, we have set the start_position parameter to a value of 11. The following will be output to the web browser console log: false You can change the position where the search will start in the string by providing a start_position parameter to the includes() method.Ĭonsole.log(totn_string.includes('e',11)) ![]() In this example, the includes() method returned true because the substring 'e' is found within 'TechOnTheNet' when performing a case-sensitive search. The following will be output to the web browser console log: true We have written the output of the includes() method to the web browser console log, for demonstration purposes, to show what the includes() method returns. We have then invoked the includes() method of the totn_string variable to determine if a substring is found within totn_string. In this example, we have declared a variable called totn_string that is assigned the string value of 'TechOnTheNet'. ![]() Let's take a look at an example of how to use the includes() method in JavaScript.įor example: var totn_string = 'TechOnTheNet'
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |