IndexOf method
Returns the character position of a substring within a string object for the first time.
Strobj.indexof (substring[, StartIndex])
Parameters
Strobj
Required option. A String object or literal.
SubString
Required option. The substring
String. indexof
String. indexof method (char, int32, int32)The index of the first matching item of the specified character in this instance. Searches start from the specified character location and checks the specified number of character
String. indexof
String. indexof method (char, int32, int32)The index of the first matching item of the specified character in this instance. Searches start from the specified character location and checks the specified number of character locations.
Jsjavascript checks whether a String contains a certain String. If you are interested in using the String object to find Sub-characters and indexOf, you can refer to the following to determine the specified directory to display ads.
The Code is as
Jsjavascript checks whether a String contains a certain String. If you are interested in using the String object to find Sub-characters and indexOf, you can refer to the following to determine the specified directory to display
Example of getting started with the JavaScript indexOf method (calculate the position where the specified character first appears in the string), javascriptindexof
JavaScript indexOf Method
The indexOf method is used to calculate the position where
Array does not have the indexOf method, which makes it troublesome to search for the index of an element in an Array. Therefore, Array is extended through prototype. prototype. indexOf (), but there is a problem when traversing the Array. The Array
Use of the indexOf method String type in the JavaScript Array
Let's take a look at the well-known string usage.
let str = 'orange'; str.indexOf('o'); //0 str.indexOf('n'); //3 str.indexOf('c'); //-1
Here 0 and 3 are the positions where o and n
ArticleDirectory
Syntax
Description
Instance
Reprinted ......
String. indexof method (value, [startindex], [count])
The index of the first matching item of the specified character in this instance. Searches start
Returns the first occurrence of a substring in a String object.
Public indexOf (value: String, [startIndex: Number]): NumberSearch for the string, and return the position of the first matching item of the value found at or after the startIndex
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.