var mainText = "microsoft";
var isSubstring = mainText.indexOf("soft") > -1
alert(isSubstring);
In the example, it checks for the substring "soft" within the main string "microsoft".
As it find "soft" inside "microsoft",
mainText.indexOf("soft") evaluates to 5 and isSubstring will be true;
No comments:
Post a Comment