Ever want to find one of your JavaScript strings? Even start searching for half the string? Then you're in your good luck! The string function IndexOf allows you to provide an argument (search query), as well as an optional parameter (offset) to all of your simple search requirements.
If you're looking for a more powerful search feature, you should look at JavaScript's string search feature, which supports regular expressions but not offsets.
String music indexof function
As we have mentioned above, IndexOf has two arguments, and one of the second options is:
SearchString-you're looking for.
Offset (optional)-How far the string you want to search begins. If you want to search the entire string, ignore this argument.
IndexOf function as an example
To begin, we will find a typical URL string for the position "www". The IndexOf function will return to the position of the first game of ability.
<script type= "Text/javascript" >
var aurl = "http://www.tizag.com/";
var aposition = Aurl. indexOf ("www");
document.write ("the position of www =" + aposition);
</script>
Location is 7
If you want to follow up with this function how it's the ticket, here's the total crash:
h-0-no match
Pen-1-does not match
T-2-does not match
P-3-No Match
:-4-does not match
/-5-does not match
/-6-does not match
W-7-maybe Match
Watt-8-maybe Match
W-9-This is a race to return the position of the start of the race (7).
Let's see what happens when we add the WWW URL string to see if this function is confusing or not.
<script type= "Text/javascript"
var aurl = "Http://www.tizag.com/ var aposition = aurl.indexof ("www");
document.write ("The position of www = " + aposition);
</script>
result.
The position of www = 7