hi everyone I don't understand the method- IndexOf . I know that is is concern with a str var but i do not understand what does it do. this is my code: <script type="text/javascript">var str="Hello world!"; document.write(str.indexOf("Hello") + "<br />"); document.write(str.indexOf("World") + "<br />"); document.write(str.indexOf("world")); </script> and this is the ouput 0 -1 6 why is it like that? i need a good explanation thanx pf
The indexOf() method returns the position of the first occurrence of a specified string value in a string. http://www.w3schools.com/jsref/jsref_indexOf.asp What do you not get?