Play-Asia.com - Buy Video Games for Consoles and PC - From Japan, Korea and other Regions!

Javascript - String.indexOf()

 

Syntax

string.indexOf(string, num)
string.indexOf(string)

Description

The indexOf() method of an instance of the String object returns the indexed start position of the string passed. Additionally, you can specify an index, defined by num in the syntax definition, to start your search for the string specified. This method is the same as the String.lastIndexOf() method. but it starts at the beginning of the string.

Example

<script language="JavaScript">
<!--

var myString = new String("Hello, World!");

document.write(myString.indexOf("W")); //result is 7
document.write(myString.indexOf("w")); //result is -1 document.write(myString.indexOf("l", 4)); //result is 10 //--> </script>

 

 
Visitor Review Write a review
No visitor review for this page yet
Write a review
Rating:
Text:
Name:
Email:
(optional)
 
Code:
 

Search:
Shopping Store Online
Clothes (25)
Gift shop (69)
Hand-made (27)
Luxuries (47)
Others (42)
Programming Tutorial
ASP (14)
CSharp (29)
HTML (10)
JavaScript
charAt method
charCodeAt method
concat method
indexOf method
lastIndexOf method
replace method
Photoshop (9)
PHP (11)
Entertainment
Anime (6)
E-Cards (12)
Games (20)
Music (7)