Returns the position of the first occurrence of a substring.
SyntaxstrObj. indexOf( subString [, startIndex ])
The following example illustrates the use of the indexOf method.
var str = "original equipment manufacturer";
var s = "equip is at position " + str.indexOf("equip");
s += "<br />";
s += "abc is at position " + str.indexOf("abc");
document.write(s);
Remarks
The indexOf method returns the beginning of the substring in the String object. If the substring is not found, -1 is returned.
If startindex is negative, startindex is treated as zero. If it is greater than the highest index, it is treated as the highest index.
Searching is performed from left to right. Otherwise, this method is identical to lastIndexOf.
See also Other articles AttributionsMicrosoft Developer Network: Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4