Categories
JavaScript Answers

How to find first index of a string after index with JavaScript?

Spread the love

Sometimes, we want to find first index of a string after index with JavaScript.

In this article, we’ll look at how to find first index of a string after index with JavaScript.

How to find first index of a string after index with JavaScript?

To find first index of a string after index with JavaScript, we call indexOf with the 2nd argument.

For instance, we write

const index = str.indexOf("s", startIndex);

to call indexOf to find the first 's' at startIndex or after.

Conclusion

To find first index of a string after index with JavaScript, we call indexOf with the 2nd argument.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *