js check if string contains character
var string = "foo",
substring = "oo";
console.log(string.includes(substring));const string = "foo";
const substring = "oo";
console.log(string.includes(substring));var str = "We got a poop cleanup on isle 4.";
if(str.indexOf("poop") !== -1){
alert("Not again");
}
//use indexOf (it returns position of substring or -1 if not found)"FooBar".includes("oo"); // true
"FooBar".includes("foo"); // false
"FooBar".includes("oo", 2); // falseif (your_string.indexOf('hello') > -1)
{
alert("hello found inside your_string");
}
Also in JavaScript:
- js detect mouse support
- js anonymous functions
- js int to string base
- javascript object get value by key
- angular usehash not working
- js input trigger change event when set value with js
- o que é jsonm
- viewdata array mvc razor javascript
- jquery loop through li element
- how to split two digit number in javascript
- factory function javascript
- js select keys from object
- map()
- filter in react native video
- Error: Can't resolve 'fs' webpack
- javascript javascript
- redux acions
- wait javascript
- react native settimeout
- javascript pass this to callback
- express router middleware
- angular bootstrap
- slice javascript string
- settimeout in angular