A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/javascript/String/indexOf below:

indexOf ยท WebPlatform Docs

indexOf Summary

Returns the position of the first occurrence of a substring.

Syntax
strObj. indexOf( subString [, startIndex ])
strObj
Required. A String object or string literal.
subString
Required. The substring to search for in the string
startIndex
Optional. The index at which to begin searching the String object. If omitted, search starts at the beginning of the string.
Examples

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 Attributions

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