Jump to content

string


djp1988

Recommended Posts

So if I read this correctly indexOf takes 2 arguments, the first being the characters you're looking for and the second being the number from which point in the string you start searching?How could that be == 0 ?Sorry to be of the sort that doesn't just sit on responses, but tries to understand everything :)

Link to comment
Share on other sites

Right. You pass the method the string you're searching for AND an index to begin the search on. If it finds the search string, it returns the index where the search string begins. This is more useful than a Boolean if you wanted to perform some string surgery at the return value.You specified a match only if the search string is at the start of the whole string, so we're testing for an index of zero.If the search string is not found, it returns -1 instead of false.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...