Here is the code:
<h2>Use of indexOf() method</h2>
var string = "Hello World";
var substring = "World";
var position= string.indexOf(substring,0);
document.write("<b>The substring " + substring + " is at position </b>" + position);
Output will be displayed as:
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.