Javascript examples for String Operation:String Search
Check whether a string contains a substring
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> window.onload=function(){/*w w w. j a v a 2s . c o m*/ String.prototype.contains = function(test) { return this.indexOf(test) == -1 ? false : true; }; var string = "asdf"; console.log(string.contains("as")); } </script> </head> <body> </body> </html>