By the end of this video you will be able to :-
1. Find a Particular character/string in a Main String
2. Understand the Indexof method in the easy manner
The includes() method determines whether one string may be found within another string, returning true or false as appropriate.
Syntax
Section
str.includes(searchString[, position])
Parameters
Section
searchString
A string to be searched for within this string.
position Optional
The position within the string at which to begin searching for searchString. (defaults to 0).
Return value
Section
true if the search string is found anywhere within the given string; otherwise, false if not
The indexOf() method returns the index within the calling String object of the first occurrence of the specified value, starting the search at fromIndex. Returns -1 if the value is not found.
Syntax
Section
str.indexOf(searchValue)
str.indexOf(searchValue, fromIndex)
Parameters
Section
searchValue
A string representing the value to search for. If no string is explicitly provided, searchValue will be coerced to "undefined" and this value will be searched for in the current string.
fromIndex Optional
An integer representing the index at which to start the search; the default value is 0. For fromIndex values lower than 0 or greater than str.length, the search starts at index 0 and str.length respectively.
Return value
Section
The index of the first occurrence of searchValue, or -1 if not found.
An empty string searchValue will match at any index between 0 and str.length
#Searching #includes() #indexOf()
20. Searching a Particular Character in a String - includes() Method -Finding the Index - indexOf()