Search for a String using JavaScript indexof method

The indexof method in JavaScript is used to search a string from the given input string. I returns the position of the first occurrence of the specified string in the input string. If the value is not found , it returns -1 . Also note that the indexof method is case sensitive.

How to Search for a String using JavaScript indexof method ?

Below is a sample code snippet demonstrating how to search for a string using js indexof method.

var input = "This is a blog post.";
var value = str.indexOf("");

The result of value will be 10.

If you enjoyed this post, please consider leaving a comment or subscribing to the RSS feed to have future articles delivered to your feed reader.

Leave a Reply


Interesting BlogPosts to read

How to insert bullets in to cells in Microsoft Excel ?
Do you want to insert bullets in cells of Microsoft Excel?. Here's how you can do it. How to insert ...
How to resize print area and fit to Single page in Excel 2016 ?
When you try to print a worksheet in Microsoft Excel 2016 , you may notice that the content might ov...
How to find the Created and Last Modified time in Microsoft Excel ?
You can easily find out the exact date and time when the excel workbook was created and modified usi...