indexOf() : Find first occurrence of a value in a string in JavaScript
JS Script:
<html> <body> <script type="text/javascript"> var str="Pritesh Taral"; document.write(str.indexOf("r") + "<br />"); document.write(str.indexOf("TARAL") + "<br />"); document.write(str.indexOf("Taral")); </script> </body> </html>
Output in Browser :
1 -1 8