Is there a javascript method to find out if a string is part of another string?
I need to find out if one string is in another and return true or false, or something similar.
just remembered having read someth开发者_运维技巧ing about indexof returning something like -1 if it doesn't find something?
Use the indexOf
function of String:
var str = "something";
var other = "thi";
if (str.indexOf(other) != -1) {
// other is a part of the original string.
}
精彩评论