What are the differences between indexOf() and lastIndexOf()?

In this blog, I will show you What are the differences between indexOf() and lastIndexOf() ?

The differences between indexOf and lastIndexOf methods:

indexOf(): This will return the index of the first occurrence of specific text in a string.

For example:

var str = 'Hello firend, how are firend';
str.indexOf('firend') // return 6

lastIndexOf(): This will return the index of the last occurrence of specific text in a string.

For example:

var str = 'Hello firend, how are firend';
 str.lastIndexOf('firend') // return 22

Hope this blog is helpful for you ,Thanks for reading this blog.

What are the differences between indexOf() and lastIndexOf()expoundsofttechsolution