IndexOf-3

 

Example of JavaScript indexOf function with starting index. See the code snippet:

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <button onclick="findPosition()">Find the position of character</button> <p id="sample"></p> <script> function findPosition() { var str = "Hello world, welcome to the India."; var n = str.indexOf("e",5); document.getElementById("sample").innerHTML = n; } </script> </body> </html>
Output