Question:What is the function of indexOf()? 

Answer The indexOf() method returns the position of the first occurrence of a specified value in a string. This method returns- 1 if the value which is searched never occurs. Example:
var str="Hello world, welcome to Bangladesh."
var ind=str.indexOf("welcome");
Output:13 

+ Report
Total Preview: 981
What is the function of indexOf()?
Copyright © 2024. Powered by Intellect Software Ltd