Question

How to check whether a string contains a substring in JavaScript?


Annonce
Ad

Answer

var string = "Text you want to search in";
var substring = "to";
if (string.search(substring)!==-1)
{
	// If the string contains the substring
	...
}


[source]
# ID Query