.search() help

Discussion in 'JavaScript' started by bdfsar, Apr 24, 2013.

  1. #1
    i dont understand the .search()

    in this example i dont understand why the output is 15

    http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_search2
     
    bdfsar, Apr 24, 2013 IP
  2. rnilsson

    rnilsson Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    1
    #2
    The occurance of "blue" starts in position 15.
     
    Last edited: Apr 24, 2013
    rnilsson, Apr 24, 2013 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #3
    To be more specific, search is case sensitive, so:

    Mr. Blue has a blue house
    0123456789012345678901234
                   ^ match
    Code (markup):
    Pretty simple...
     
    deathshadow, Apr 27, 2013 IP