JavaScript string contains

This is a simple function in JavaScript, I use it to check if a string contains another string.The different in this function is that the return value is the position+1.So you could use it in an If without to check the return value manually, just see my test from 1 to 3.

This is the function:

Now we make a little test to see if it work:

Seems good:

3 thoughts on “JavaScript string contains”

  1. whoah this weblog is magnificent i really like reading your
    articles. Stay up the good work! You already know,
    lots of persons are searching round for this information, you could aid them greatly.

    View Comment

Leave a Reply

Your email address will not be published.

2 × one =