How can we check if one string contains another substring?

Answer

indexOf returns the position of the string in the other string. If not found, it will return -1:

var s ="foo";
 alert(s.indexOf("oo")>-1);

All windows Questions

Ask your interview questions on windows

Write Your comment or Questions if you want the answers on windows from windows Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---