The nethod -indexOf in js

Discussion in 'JavaScript' started by progfrog, Feb 18, 2008.

  1. #1
    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
    ;)
     
    progfrog, Feb 18, 2008 IP
  2. MMJ

    MMJ Guest

    Messages:
    460
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #2
    MMJ, Feb 18, 2008 IP