Jump to content

string


djp1988
 Share

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...