Locate a string in another string
ES6
ECMAScript 6 introduced String.prototype.includes:
1 | const string = "foo"; |
ES5
In ECMAScript 5 or older environments, use String.prototype.indexOf, which returns -1 when a substring cannot be found:
1 | var string = "foo"; |